This page lists general standards to adhere to when developing the CLI of our application.
Overview
Our CLI should adopt a “noun” “verb” pattern. This means that the first argument the CLI receives should refer to a noun (essentially a ‘model’ from the MVC world) and the second argument should be a “verb” (which is something to do with the noun).
This is a common pattern used in many modern CLIs!
Architecture
The CommandLineParser class handles command line parsing. The parse function receives command line arguments (via the magic args variable). It has several functions that help you along.
Parseis a simple function that receives command lineargsand returns both theNounand theVerb- E.g.,
credit list→(Credit, List)
- E.g.,
GetCommandLineArgsreturns the arguments after theNounandVerb- E.g.,
credit list→[] - E.g.,
credit list abc→["abc"]
- E.g.,
ParseWithArgsis a combination of bothParseandGetCommandLineArgs- E.g.,
credit list abc→((Credit, List), ["abc"]
- E.g.,