A subcommand is a command nested under a parent command, representing a more specific command-line operation. Frameworks such as Cobra provide routing, help text, flags, and shell autocompletion for command hierarchies. section 2.1.4
A practical subcommand implementation typically provides:
- Generated usage and help output so users can discover commands and options. section 2.1.4
CLI calculator
A calculator can expose arithmetic as subcommands: `add <number1> <number2>`, `sub`, `mul`, and `div`. Each command parses its arguments and invokes the corresponding operation.
