Skip to main content

Typer Shell!

Beautiful command-line shell with Typer!

This is just an update to click-shell for typer.

I also added some features like:

  • better help by default
  • support for typer default functions (just name one of your commands 'default' and it will be triggered when nothing else is recognized)
  • easily drop into an ipython terminal with the local context loaded with 'shell'
  • rich sample commands for file operations, tables, progress bars, and more

See it in action!

And checkout the demo script:

To run the demos, you can execute them with uv run:

uv run python demo/demo.py
uv run python demo/simple_demo.py

Or use the convenient just commands:

just demo
just simple-demo

There are also sample helper functions in typer_shell/samples.py that you can use in your own applications. These include:

Sample Commands

  • File Operations: ls, cat, pwd - basic file system navigation
  • Rich UI: table, progress, panel - demonstrate rich formatting capabilities
  • Interactive: ask - prompt for user input with rich styling
  • System: env, date - show environment variables and current time
  • Development: shell - drop into IPython with current context

Add them to your shell with:

from typer_shell.samples import add_sample_commands
add_sample_commands(app)

Using Callbacks

Because typer-shell uses Typer's callback mechanism to launch the interactive shell, you cannot use the standard @app.callback() decorator, as it will conflict and prevent the shell from loading.

If you need to run code before the shell launches (for example, to set up state), you can pass a function to the user_callback parameter in make_typer_shell.

Your function will be called with the Typer.Context object before the shell starts.

import typer
from typer_shell import make_typer_shell

def my_setup_logic(ctx: typer.Context):
    print("This runs before the shell starts!")
    # You can access and modify the context object here
    ctx.obj.my_value = 42

app = make_typer_shell(user_callback=my_setup_logic)

@app.command()
def my_command(ctx: typer.Context):
    print(f"my_value is: {ctx.obj.my_value}")

if __name__ == "__main__":
    app()

Development

This project uses uv for dependency management and ruff for linting/formatting.

# Setup development environment
uv sync

# Run demos
just demo
just simple-demo

# Code quality
just format  # Format code
just lint    # Check for issues
just fix     # Auto-fix issues

# Build and publish
just build
just publish

Metadata

Release files for typer-shell 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for typer-shell 1.0.3
File Size Uploaded
typer_shell-1.0.3.tar.gz 18.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for typer-shell 1.0.3
File Interpreter ABI Platform
typer_shell-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 36.1 kB

Release files / typer_shell-1.0.3.tar.gz

Download URL typer_shell-1.0.3.tar.gz
Size 18.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e842b8e75677bfaea510bf373891b10700e001d32ed958713de7dcafb7871ef6
BLAKE2b-256 checksum
How to use checksums
9bc40f75a24961d93d4c2ba0352342beec7993799d19b107ae303469dc04efe0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.15

Release files / typer_shell-1.0.3-py3-none-any.whl

Download URL typer_shell-1.0.3-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d22a6ff4512f097a6547f831b2a1ad08ae3cdbf070e8fdf72fadeacf0244f632
BLAKE2b-256 checksum
How to use checksums
c5df9bf155ac9fb1aaadb2463fd1baa21e2adc1bb899311a5ebd4629bb98285f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.15

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.6

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page