Skip to content

Latest commit

 

History

History
152 lines (100 loc) · 2.58 KB

File metadata and controls

152 lines (100 loc) · 2.58 KB

Important note

A newer version of this Cookiecutter (using the amazing Typer!) is currently work in progress and available here.

A cookiecutter to bake tasty Python Click CLI tools 🍪

Come to the dark side... We have cookies!

Comes with:

  • Containerization
  • Pre-commit hooks
  • black
  • click
  • flake8
  • mkdocs-material
  • mypy
  • packaging

Usage

Install cookiecutter.

pip install --user cookiecutter

Generate your project template using cookiecutter.

cookiecutter gh:ltpitt/cookiecutter-python-cli

Project Setup

  1. cd into project directory.

  2. Create a virtual environment.

python -m venv venv
  1. Linux / Mac - Activate it.
source venv/Scripts/activate
  1. Windows - Activate it.
source venv/Scripts/Activate.ps1
  1. Linux / Mac - Install development dependencies with editable mode to test the CLI.
make install
  1. Windows - Install development dependencies with editable mode to test the CLI.
pip install -e . -r requirements/dev.txt

Take your CLI for a spin

This Cookiecutter comes with two generic CLI commands, namely, init and hello.

NOTE

<<cli_command>> is the executable command you choose for your CLI during project setup.

<<cli_command>> init
<<cli_command>> hello

Test with Docker

CLI commands can be tested with Docker.

  1. Build an image for the CLI.

    Image is tagged <<cli_command>> name.

make docker-image
  1. Run the command inside the container.
docker-run --rm <<cli_command>> init

Documentation

  1. Linux / Mac - Install documentation-related dependencies.
make docs
  1. Windows - Install development dependencies with editable mode to test the CLI.
pip install -r requirements/docs.txt
  1. Linux / Mac - Serve the docs locally.
make serve-docs
  1. Windows - Serve the docs locally.
mkdocs serve -f docs/mkdocs.yml

Linux / Mac - Distribution

NOTE

Make sure you have account in PyPI before you try this out.

To publish you CLI to PyPI, run:

make distributions

dist directory will be created inside your project directory. Upload it to PyPI using:

twine dist/*

Linux / Mac - Help

For help related to make commands.

make help