Extended batteries for Typer - 12 CLI extensions
Project description
typer-powertools
Extended batteries for Typer — 12 powerful CLI extensions to build production-grade tools faster.
typer-powertools extends Typer with the features every professional CLI eventually needs: layered configuration, auditing, interactive shells, setup wizards, and more. Stop writing boilerplate and start building features.
12 Batteries Included
| Module | Description |
|---|---|
| config | Layered settings (pyproject.toml, .env, YAML, JSON) with Pydantic validation. |
| shell | Turn your multi-command app into an interactive REPL with history and help. |
| progress | Declarative progress bars, spinners, and task tracking via Rich. |
| audit | Transparent SQLite-backed logging of every command invocation and result. |
| i18n | Internationalization for help text and messages (files or in-memory). |
| hooks | Lifecycle hooks (before, after, error, finally) for setup and teardown. |
| cache | TTL-based result caching for expensive API calls or heavy computations. |
| middleware | Request/response pipeline for authentication, timing, retries, and more. |
| plugins | Dynamic plugin discovery from paths or installed Python packages. |
| wizard | Interactive multi-step setup wizards with validation and conditional logic. |
| templates | Project and file generation using Jinja2 templates. |
| migrations | Versioning and automatic migration of user configuration files. |
Quick Start
import typer
from typer_powertools import config_option, audit_command, cached_command, track_progress
app = typer.Typer()
@app.command()
@audit_command(app_name="myapp") # ← Logs invocation to SQLite
@cached_command(ttl=3600) # ← Caches result for 1 hour
@config_option(app_name="myapp") # ← Loads from pyproject.toml / .env
def deploy(env: str = "staging"):
for step in track_progress(range(10), description="Deploying..."):
do_work(step)
typer.echo(f"✓ Deployed to {env}")
if __name__ == "__main__":
app()
Feature Highlights
🛠 Layered Config & Pydantic
Automatically load configuration from multiple sources with strict precedence: CLI args > Env Vars > Config File > Defaults.
from typer_powertools import pydantic_config_option
from pydantic import BaseModel
class MyConfig(BaseModel):
api_key: str
timeout: int = 30
@app.command()
@pydantic_config_option(MyConfig, app_name="myapp")
def connect(cfg: MyConfig):
typer.echo(f"Connecting with {cfg.api_key}...")
🐚 Interactive Shell (REPL)
Give your users a powerful interactive environment with one line of code.
from typer_powertools import shell_command
# Registers a 'shell' command to your app
shell_command(app, prompt="myapp> ")
🕵️♂️ Transparent Auditing
Keep a permanent record of what your CLI did. Includes management commands to view history and stats.
from typer_powertools import register_audit_commands
@app.command()
@audit_command(app_name="myapp", sensitive_params=["password"])
def login(password: str):
pass
register_audit_commands(app, app_name="myapp")
# Adds: myapp audit history / myapp audit stats
🧙♂️ Setup Wizards
Build complex interactive configurations with a fluent API.
from typer_powertools import WizardBuilder
@app.command()
def init():
wizard = (
WizardBuilder("Initial Setup")
.ask("name", "Project Name?")
.choose("theme", "Select Theme", ["dark", "light"])
.ask_secret("key", "API Key")
.build()
)
results = wizard.run()
typer.echo(f"Setup complete for {results['name']}!")
🔄 Config Migrations
Evolve your configuration schema without breaking your users' setups.
from typer_powertools import MigrationManager, register_migration_commands
manager = MigrationManager("myapp")
@manager.migration("v1_to_v2", from_version="1.0", to_version="2.0")
def upgrade(config):
config["new_key"] = config.pop("old_key")
return config
register_migration_commands(app, manager)
Installation
# Install core
pip install typer-powertools
# Install with optional features
pip install "typer-powertools[cache]" # For TTL caching
pip install "typer-powertools[templates]" # For Jinja2 templates
pip install "typer-powertools[all]" # Install everything
Documentation & Learning
- Quick Reference — The ultimate cheat sheet for every API.
Examples
Check out the examples/ directory for complete applications:
core_features_demo.py— Core features in action.complete_demo.py— A massive CLI using all 12 modules.
License
Built by Muhammad Ali. Distributed under the Apache License 2.0. See LICENSE for more information.
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
File details
Details for the file typer_powertools-0.2.0.tar.gz.
File metadata
- Download URL: typer_powertools-0.2.0.tar.gz
- Upload date:
- Size: 62.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0df315d59a1be66529633a6d7d24c6608a6f0e1fcc6a3640099baa0d2db8a8d
|
|
| MD5 |
b34232455e10ccf9fc76032ac039acbe
|
|
| BLAKE2b-256 |
2947d72c818aad61eb0f6abe54d73aca12a459f9eadd31741ec7131c27735ebb
|
Provenance
The following attestation bundles were made for typer_powertools-0.2.0.tar.gz:
Publisher:
publish.yml on m-ali-ubit/typer-powertools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typer_powertools-0.2.0.tar.gz -
Subject digest:
a0df315d59a1be66529633a6d7d24c6608a6f0e1fcc6a3640099baa0d2db8a8d - Sigstore transparency entry: 1471716806
- Sigstore integration time:
-
Permalink:
m-ali-ubit/typer-powertools@0ff2b5f3849cd32bcaa2376b3c02e6cf45b4d721 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/m-ali-ubit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0ff2b5f3849cd32bcaa2376b3c02e6cf45b4d721 -
Trigger Event:
push
-
Statement type:
File details
Details for the file typer_powertools-0.2.0-py3-none-any.whl.
File metadata
- Download URL: typer_powertools-0.2.0-py3-none-any.whl
- Upload date:
- Size: 58.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e940d7de59979965aaa24994835f0233e5f748c64b7dec21898f504d6335d06
|
|
| MD5 |
a7aee453f1c9cc5405820dfce5f14de0
|
|
| BLAKE2b-256 |
46090895b9406eac90c00c33ea233e24be53440f9128334ccb6a6911b938932e
|
Provenance
The following attestation bundles were made for typer_powertools-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on m-ali-ubit/typer-powertools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typer_powertools-0.2.0-py3-none-any.whl -
Subject digest:
8e940d7de59979965aaa24994835f0233e5f748c64b7dec21898f504d6335d06 - Sigstore transparency entry: 1471717055
- Sigstore integration time:
-
Permalink:
m-ali-ubit/typer-powertools@0ff2b5f3849cd32bcaa2376b3c02e6cf45b4d721 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/m-ali-ubit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0ff2b5f3849cd32bcaa2376b3c02e6cf45b4d721 -
Trigger Event:
push
-
Statement type: