pyCLI
is a template project to structure your next CLI!
pyCLI
is a command line tool, which can be used like this:
Usage: pyCLI [OPTIONS]
INSERT SHORT DESCRIPTION WHAT THE CLI DOES HERE
Options:
--version Show the version and exit.
-v, --verbose Increase log verbosity
--ca-bundle TEXT The default certificate bundle. [default:
/etc/ssl/certs/ca-certificates.crt]
--pycli-message TEXT The message which will be printed to the shell.
[default: Ciao]
-h, --help Show this message and exit.
pyCLI
can read all of its command line parameters from environment variables (but not from a .env
file).
The format of the environment variable names can be directly derived from the parameter's name, e.g.:
--pycli-message
-> PYCLI_MESSAGE
In case one doesn't want to export the environment variables one by one, it can be convenient to put all the variables in a .env
file and export them like this:
export $(xargs < .env)
This will grab all the environment variables from the .env
file and export them in the current shell.
In case you modify anything in your
.env
file don't forget to re-export the values, as they won't be picked up automatically.
pyCLI
will prioritize command line options. If none are given it will first check for environment variables and if those aren't given either the default value is used.
pip install pyCLI
Please do contribute! Issues and pull requests are very welcome!
Thank you already in advance for your help improving this CLI template!
- Clone the repository
git clone https://github.com/tillstud/pyCLI
- Create and activate a virtual environment
python3 -m venv venv
source ./venv/bin/activate
To deactivate the venv type
deactivate
in your shell
- Install the package in editable mode with the dev requirements
pip install -e .["dev"]
This will also install the related build and publish packages, not just the packages for development.
- Update the versions in
.pre-commit-config.yml
and install the pre-commit script
pre-commit autoupdate
pre-commit install
- Set your shell variables
export $(xargs < .env)
I can recommend using pyenv to manage your local python versions.