targ
Build a Python CLI for your app, just using type hints and docstrings.
What it is and what it does
targ is a CLI framework that builds command-line interfaces directly from Python function signatures and docstrings. You register type-annotated functions with a CLI object, and targ automatically generates argument parsing, help text, and command dispatch—no special syntax or configuration files needed. The package extracts parameter documentation from docstrings and uses type hints to determine argument types and validation.
It's designed for developers who want to expose Python functions as CLI tools without learning argparse or click's decorator syntax. The framework depends on colorama for terminal output formatting and docstring-parser to extract parameter descriptions from docstrings. It supports Python 3.10 through 3.14 and has been actively maintained since its 2020 release.
Use it for:
- Quickly expose internal Python functions as command-line tools for scripting or automation without writing CLI boilerplate.
- Build simple admin or utility CLIs where function signatures naturally map to command arguments.
- Generate self-documenting CLI tools where help text is automatically derived from existing docstrings.
- Prototype CLI applications during development when you want minimal overhead before committing to a larger framework.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Generates a command-line interface from type-annotated Python functions and their docstrings, with no additional configuration required.
Yes. targ is a lightweight, actively maintained tool that solves a real problem—turning functions into CLIs with zero special syntax. Low install friction, permissive license, no known vulnerabilities, and recent activity make it a safe choice for projects that need simple CLI generation. Best suited for straightforward use cases; verify whether it handles your specific type complexity before adopting for complex argument scenarios.
Install
targ on PyPI
pip
pip install targuv
uv add targpoetry
poetry add targInstalling targ
Before you install
Low friction: pure Python wheel with only two lightweight dependencies (colorama for terminal colors and docstring-parser for documentation extraction). Actively maintained with a recent release 26 days ago.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
pip install targ
from targ import CLI
def add(a: int, b: int):
"""Add two numbers."""
print(a + b)
if __name__ == "__main__":
cli = CLI()
cli.register(add)
cli.run()
Requires Python 3.10 or later.
Verify before relying
- Whether the package handles complex type hints (unions, generics, optional types) beyond basic int/str/bool.
- Support for subcommands, command groups, or nested CLI hierarchies.
- Whether environment variables or configuration files can be integrated with the CLI.
- Performance characteristics when registering many functions or handling large argument sets.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — colorama, docstring-parser |
| Maintenance | actively maintained — 26 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 690,227/month — #5,330 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: targ-0.7.0-py3-none-any.whl
Tags
More Build Tools packages
Provides reusable utilities for Python…
permissive · top 100 on PyPI
tqdmWraps any iterable to display a real-time…
copyleft · top 100 on PyPI
pippip is the standard installer for Python…
permissive · top 100 on PyPI
hatchlingHatchling is a standards-compliant Python build…
permissive · top 100 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
pre-commitpre-commit is a framework for installing and…
permissive · top 1,000 on PyPI
arguablyConverts Python functions and their docstrings…
unclear · top 15,000 on PyPI
clizeClize turns Python functions into command-line…
permissive · top 15,000 on PyPI
tyrotyro generates command-line interfaces and…
permissive · top 5,000 on PyPI
argbindArgBind binds function and class arguments to…
permissive · top 15,000 on PyPI
mandomando wraps argparse to let you build…
permissive · top 5,000 on PyPI
entrypoint2Converts Python function signatures and…
permissive · top 15,000 on PyPI
docoptParses command-line arguments based on a help…
permissive · top 5,000 on PyPI
cycloptsCyclopts is a CLI framework that converts…
permissive · top 1,000 on PyPI
jsonargparsejsonargparse creates command-line interfaces…
permissive · top 5,000 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI