Skip to content
/ pyCLI Public template

⌨️ pyCLI is a template project to structure your next CLI!

License

Notifications You must be signed in to change notification settings

tillstuder/pyCLI

Repository files navigation

GitHub license GitHub contributors GitHub pull-requests GitHub issues

pyCLI

pyCLI is a template project to structure your next CLI!

Usage

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.

Configuration

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.

Installation

pip install pyCLI

Contribute

Please do contribute! Issues and pull requests are very welcome!

Thank you already in advance for your help improving this CLI template!

Development

  1. Clone the repository
git clone https://github.com/tillstud/pyCLI
  1. Create and activate a virtual environment
python3 -m venv venv
source ./venv/bin/activate

To deactivate the venv type deactivate in your shell

  1. 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.

  1. Update the versions in .pre-commit-config.yml and install the pre-commit script
pre-commit autoupdate
pre-commit install
  1. Set your shell variables
export $(xargs < .env)

Optional

I can recommend using pyenv to manage your local python versions.

About

⌨️ pyCLI is a template project to structure your next CLI!

Topics

Resources

License

Stars

Watchers

Forks

Languages