Receiving the input and user interaction
The primary methods for receiving input via a command-line application are through its subcommands, arguments, and options, also known as flags. However, additional input can come in the form of stdin
, signals, and control characters. In this section, we’ll break down each different input type and when and how to interact with the user.
Defining subcommands, arguments, and flags
Before we start characterizing the main types of input, let’s reiterate the structural pattern that explains the generalized location for each input type in terms of its predictability and familiarity. There’s an excellent description of the pattern within the Cobra Framework documentation. This is one of the best explanations because it compares the structure to natural language and, just like speaking and writing, the syntax needs to be properly interpreted:
APPNAME NOUN VERB –ADJECTIVE
Note
The argument is the noun and the...