Template for Command Line Interface (CLI) tool in Python
Install Command Line Tools (CLT) for Xcode:
xcode-select --install
Install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install Python version manager pyenv
brew install pyenv
Configure project:
source configure.sh
Open the project in Visual Studio Code:
code .
echo "John" > name.txt
cli-py greet name.txt
cli-py greet --language es name.txt
cli-py greet -l bg name.txt
pytest
# build
mkdocs build
# serve
mkdocs serve
# open docs in browser
open http://127.0.0.1:8000
# init the project
poetry init \
--no-interaction \
--name "cli-py" \
--description "CLI tool for greeting users in different languages" \
--license "Apache-2.0" \
--python "^3.12"
# add `click` package
poetry add click
# add `dev` packages
poetry add --dev pytest
poetry add --dev mkdocs mkdocs-material mkdocstrings[python]
Create the following project structure:
cli-py/
├── cli_py/
│ ├── __init__.py
│ └── main.py
├── pyproject.toml
├── README.md
└── LICENSE
Init docs:
mkdocs new .