For accepting input, if stdin is a tty then prompt rather than forcing the user to specify a flag. Never require a prompt though. The user needs to be able to automate the CLI in a script so allow them to override prompts always.
Before executing the command, display what it looks like, to help the users learn how to use the CLI without the prompt.
E.g (the command following the interactive prompt shown below, huge thanks to Amy, working on MAAS UX for the awesome prototype)
$ maas deploy machine-name os=ubuntu release=18.04
Question objects containing question related values.
defaults: (String | Number | Boolean | Array | Function)
Default value(s) are used when nothing is entered or the function returns the default value(s).
validate: (Function) Should return
trueif the value is valid, and an error message (String) otherwise. If
falseis returned, a default error message is provided.
Questions with a list of items for a user to select will contain the
autocomplete - presents a list of option as the user types and display the nearest neighbours in the list as they type.
When a user typed the wrong argument, the prompt can suggest the nearest neighbour based on the input string.
When the prompt requires a user to add input in a certain format, it will contain the
Some input format might require validation before proceeding such as
number input, etc.
For instance, the input prompt that requires a number input might need to validate that an input is a valid number before submitting. If an input is not a number, it will print an error message.
When a prompt is asking for a
noanswer, it is recommended to have a
defaultanswer as part of the question, even though default is an optional choice.
> Register MAAS as KVM host [default = no] : (y/N)
The prototype in this example uses inquirerJS to prototype the interactive prompts.