Skip to main content

A shell for typer apps with autocompletion and history

Project description

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'
  • each shell can have local parameters with helper functions for loading and saving them from files

See it in action!

And checkout the demo script:

#!/usr/bin/env python


from rich import print
from typer import Context

from typer_shell import make_typer_shell


class App:
    def __init__(self, name: str = "Bob"):
        self.name = name


app = make_typer_shell(prompt="🔥: ", obj=App(), params={"name": "Bob"}, params_path="params.yaml")
inner_app = make_typer_shell(prompt="🌲: ", params={"name": "Bob"}, params_path="innerparams.yaml")
app.add_typer(inner_app, name="inner")


@app.command()
@inner_app.command()
def foobar(name: str = "Bob"):
    "Foobar command"
    print("Hello", name)


@app.command()
def name(ctx: Context, name: str = "Bob"):
    "Name command"
    print("Hello", name)


# Set both the shell and the inner shell to have the same default
@app.command(hidden=True)
@inner_app.command(hidden=True)
def default(ctx: Context, line: str = "Bob"):
    "Name command wrapper for default"
    ctx.invoke(name, ctx=ctx, name=line)


if __name__ == "__main__":
    app()

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

typer_shell-0.1.12.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

typer_shell-0.1.12-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file typer_shell-0.1.12.tar.gz.

File metadata

  • Download URL: typer_shell-0.1.12.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/6.8.0-45-generic

File hashes

Hashes for typer_shell-0.1.12.tar.gz
Algorithm Hash digest
SHA256 dc7742649e6dcdd77cc3ab909cbac23438a2e3ad6cf847cadc35bb0937b4965c
MD5 bb75e4b939d5521d2b9faf81cc8bb221
BLAKE2b-256 2ab0e20a7694ba55fb247d17a1af8391d69261b9803a3e6773d43b12a7f5608a

See more details on using hashes here.

File details

Details for the file typer_shell-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: typer_shell-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/6.8.0-45-generic

File hashes

Hashes for typer_shell-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 63b0b6b46b24c906d027b410bc521eeabc893f72c970318a7dd7034e95186caa
MD5 c353b05528c0586adfdb7b93f7f732ee
BLAKE2b-256 aa3d6e2514949fe76b7f99de3d0ac2e85ca36c31763ade8441450f6c2e6d97db

See more details on using hashes here.

Supported by

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