Skip to main content

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 and pyproject.toml
  • Building a CLI with Typer
  • Packaging with Hatchling + python -m build
  • Testing with pytest and Typer's built-in CliRunner
  • 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, what pip actually 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pranavpy-0.1.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pranavpy-0.1.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file pranavpy-0.1.0.tar.gz.

File metadata

  • Download URL: pranavpy-0.1.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pranavpy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 658f66ba7bfc60305750d645480515fa8de765f703a54883373ea8dff74e0997
MD5 5993373183c7da3f27208a049c5a3418
BLAKE2b-256 1079205f17095a5728bf7ad24e826c78883062d745543c8df460620a781650fa

See more details on using hashes here.

File details

Details for the file pranavpy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pranavpy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pranavpy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c3828eb0c018711863a790474089c9252c9d0182d290fbaf962b369f8a4cd37c
MD5 976b14d296182589b4590116299e9308
BLAKE2b-256 12557184b5252346be7e16485fa5254148d97b84855cd1eb1380c53fe8119f80

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page