Learn argparse
Build command-line interfaces with arguments, options, help and subcommands
argparse is the standard library module for parsing command-line arguments. You declare the positional arguments, options and subcommands your script accepts, and it converts and validates them, generates --help output and reports usage errors. It's the dependency-free way to turn a script into a proper CLI tool.
Before you start
How deep do you want to go?
1. EssentialsRead and write simple code, do the everyday basics
2. PracticalUse it productively at work, with the usual idioms
3. AdvancedThe less common features, performance and trade-offs
4. ExpertInternals and the edge cases experts know