Pranav's CLI Tool
Project description
pranavpy
A small practice CLI tool built with Typer, created to learn how Python command-line apps are structured, packaged, tested, and published to PyPI.
It does one thing: greets you by name.
$ pranavpy --name Alice
Hello Alice!
Why this project exists
This is a learning sandbox for the full lifecycle of a Python CLI app:
- Structuring a project with a
src/layout andpyproject.toml - Building a CLI with Typer
- Packaging with Hatchling +
python -m build - Testing with
pytestand Typer's built-inCliRunner - Publishing to (Test)PyPI with
twine
Project layout
pranavpy/
├── pyproject.toml # project metadata, dependencies, build config
├── makefile # shortcuts for install/test/build/publish
├── README.md
├── src/
│ └── pranavpy/
│ ├── __init__.py
│ └── cli.py # the Typer app
└── tests/
└── test_cli.py
The entry point is wired up in pyproject.toml:
[project.scripts]
pranavpy = "pranavpy.cli:app" # the `pranavpy` command calls app() in cli.py
Requirements
- Python 3.10+
Getting started
Create a virtual environment and install the project in editable mode with dev tools:
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
Editable mode (-e) means edits to cli.py take effect immediately — no reinstall needed.
Usage
pranavpy --name Alice # Hello Alice!
pranavpy --help # show all options
The --name option is required; running pranavpy with no arguments exits with an error.
Development
This repo uses a makefile for common tasks:
| Command | What it does |
|---|---|
make install |
Install the package + dev dependencies (editable) |
make test |
Run the test suite with pytest |
make clean |
Remove dist/ and build artifacts |
make build |
Clean, test, build the wheel/sdist, and check them |
make publish |
Build and upload to PyPI |
make publish-test |
Build and upload to TestPyPI |
Running tests
make test
# or directly:
pytest
Tests use Typer's CliRunner, which invokes the app in-process (no subprocess needed):
from typer.testing import CliRunner
from pranavpy.cli import app
runner = CliRunner()
def test_main():
result = runner.invoke(app, ["--name", "Alice"])
assert result.exit_code == 0
assert "Hello Alice" in result.output
Building & publishing
The build reads pyproject.toml and produces two files in dist/:
.whl(wheel) — a zip of the package, whatpipactually installs.tar.gz(sdist) — the raw source, a fallback for platforms without a wheel
Release checklist:
# 1. Bump the version in pyproject.toml
# 2. Make sure tests pass
pytest
# 3. Clean old builds, build, and verify
make build # runs clean + test + build + twine check
# 4. Try it on TestPyPI first (separate account at test.pypi.org)
make publish-test
# 5. Publish for real
make publish
Installing a published version for end users (no dev tools needed):
pipx install pranavpy
License
Practice project — not intended for distribution.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters