Python Command Line Interfaces¶
Command Line Interfaces using Click¶
Click is a Python package for creating command line interfaces in a composable way. It uses a declarative syntax that makes it easy to create CLI commands and easy and to understand them later. However to use Click, the Click package must be installed.
Command Line Interfaces using argparse¶
Argparse is included in the python standard library and so does not require any additional packages. It uses an imparative syntax.
Read more in the argparse documentation.
Add a Callable CLI Command To Your Package¶
To create a callable command at the top level of your package create a folder called
It should contain two files:
# -*- python -*- from lsst.sconsUtils import scripts scripts.BasicSConscript.shebang()
A file that has the name of the CLI command the user will call. This file should contain as little implementation as possible. The ideal simplest case is to import an implementation function and call it. This makes the implementation testable and reusable.