Use library 'click' to generate a Command Line Interface for script 'pyxel/run.py'
Use click
instead of argparse
to create a CLI for script pyxel/run.py
.
Example before using click
:
$ pyxel --help
usage: pyxel [-h] [-v] [-V] [-c CONFIG] [-s SEED] [--download-examples [DOWNLOAD_EXAMPLES]] [-f] [-cm CREATEMODEL]
Pyxel detector simulation framework. Pyxel is a detector simulation framework, that can simulate a variety of detector effects (e.g., cosmic rays, radiation-induced CTI in CCDs, persistence in
MCT, charge diffusion, crosshatches, noises, crosstalk etc.) on a given image.
optional arguments:
-h, --help show this help message and exit
-v, --verbosity Increase output verbosity (-v/-vv/-vvv) (default: 0)
-V, --version show program's version number and exit
-c CONFIG, --config CONFIG
Configuration file to load (YAML) (default: None)
-s SEED, --seed SEED Random seed for the framework (default: None)
--download-examples [DOWNLOAD_EXAMPLES]
Install examples to the specified directory, default is /pyxel-examples. (default: None)
-f, --force Force flag for saving the examples. (default: False)
-cm CREATEMODEL, --createmodel CREATEMODEL
Use: -cm arg1/arg2. Create a new module in pyxel/models/arg1/arg2 using a template (pyxel/templates/MODELTEMPLATE.py) (default: None)
And with click
:
$ pyxel
Usage: pyxel [OPTIONS] COMMAND [ARGS]...
Pyxel detector simulation framework.
Pyxel is a detector simulation framework, that can simulate a variety of
detector effects (e.g., cosmic rays, radiation-induced CTI in CCDs,
persistence in MCT, charge diffusion, crosshatches, noises, crosstalk
etc.) on a given image.
Options:
-v, --verbosity Increase output verbosity (-v/-vv/-vvv) [default: 0]
--version Show the version and exit.
--help Show this message and exit.
Commands:
config Run Pyxel with a YAML configuration file.
create-model Create a new model.
download-examples Install examples to a specified directory.
And with click
:
$ pyxel config --help
Usage: pyxel config [OPTIONS] CONFIG
Run Pyxel with a YAML configuration file.
Options:
-s, --seed INTEGER Random seed for the framework.
--help Show this message and exit.
$ pyxel create-model --help
Usage: pyxel create-model [OPTIONS] MODEL_NAME
Create a new model.
Use: arg1/arg2. Create a new module in ``pyxel/models/arg1/arg2`` using a
template (``pyxel/templates/MODELTEMPLATE.py``)
Options:
--help Show this message and exit.
And with click
:
$ pyxel download-examples --help
Usage: pyxel download-examples [OPTIONS] [FOLDER]
Install examples to a specified directory.
Default folder is './pyxel-examples'.
Options:
-f, --force Force flag for saving the examples.
--help Show this message and exit.
Edited by Frederic Lemmel