Command line application ingredients:
- arguments, options(flags)
- stdin, stdout, stderr
- meaningful exit code and logging
- signal handle
- output colors: rich, colorama modules
Non-click
If no click, how to split subcommand into dedicated file, here is a good example with argparse
and importlib
module.
Click
Introduction video: https://youtu.be/kNke39OZ2k0
My bootstrap click subcommand lazy loading framework github repo, then I can focus on the functional part.
- Arguments, can also be used to check file existence, read/write file or stdin/stdout.
- Options, commonly use features: is_flag, help message, default value, type with choice.
- Commands and Groups
- Context
Colorful output, but logging
module(for general purpose) is prefered, 如果不是complex应用,其实使用click 自带的颜色输出就足够了.