This tutorial uses the built-in Pyton module
Complex command-line programs can be simplified with the concept of
sub-commands. Sub-commands are named commands as the first argument passed into a program, where each sub-command has it's own unique set of required and optional arguments.
A well-known program with sub-commands is
git command-line program has various sub-commands such as:
Each one of these sub-commands has it's own required and optional arguments.
If you find yourself starting to add options that are only applicable when certain other arguments are present, then it might be time to look into sub-commands.
argparse has sub-command support through the use of
add_subparsers(). The following working example shows a Python program which has two sub-commands,
- Python Sets
- An Introduction To Asynchronous Programming In Python
- Installing Python
- Python Classes And Object Orientated Design
- Python Type Annotations
- programming languages
- argument parser