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.
Parse
is a simple function that receives command lineargs
and returns both theNoun
and theVerb
- E.g.,
credit list
→(Credit, List)
- E.g.,
GetCommandLineArgs
returns the arguments after theNoun
andVerb
- E.g.,
credit list
→[]
- E.g.,
credit list abc
→["abc"]
- E.g.,
ParseWithArgs
is a combination of bothParse
andGetCommandLineArgs
- E.g.,
credit list abc
→((Credit, List), ["abc"]
- E.g.,