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.

Easter egg 🥚

Run it with --name Pranav (case-insensitive) and it prints a little ASCII-art banner of the creator's name before the greeting:

$ pranavpy --name Pranav

        ██████  ██████   █████  ███    ██  █████  ██    ██
        ██   ██ ██   ██ ██   ██ ████   ██ ██   ██ ██    ██
        ██████  ██████  ███████ ██ ██  ██ ███████ ██    ██
        ██      ██   ██ ██   ██ ██  ██ ██ ██   ██  ██  ██
        ██      ██   ██ ██   ██ ██   ████ ██   ██   ████

Hello Pranav!

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.1.tar.gz (4.9 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.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pranavpy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e0831bed6ce597197470dbddd23c411836b7d3dbaec60957728da88c5952dc44
MD5 de78d9d30e71513dc47ef1a2fbb7f1b1
BLAKE2b-256 80dad6dcc832dea4443b61beeffd54708b8e1f14af5d472842dfebbed43a475f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pranavpy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7b74e7b952108f1f52584a2881f90765fdf3ad8527a40250c2933d020f77317a
MD5 c892c91aeb8aa845ca4a5a5ed43b7fef
BLAKE2b-256 6716357e741433b8706a5bf437005c32812164fe03a6999042dfe4d8305f443f

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