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
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
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
typer_shell-0.1.10.tar.gz
(16.7 kB
view details)
Built Distribution
File details
Details for the file typer_shell-0.1.10.tar.gz
.
File metadata
- Download URL: typer_shell-0.1.10.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/6.5.0-41-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60a43dd85e9aca2a8091f8ff4a2c41416839e92f089c936f25d2bd00d17835db |
|
MD5 | d06581fac47d36900f5c363858a617d6 |
|
BLAKE2b-256 | 201c6a6d8dfed6c21cf6c9bf6ab22b7126dc78bc10d60903ac83847e8ad1cb77 |
File details
Details for the file typer_shell-0.1.10-py3-none-any.whl
.
File metadata
- Download URL: typer_shell-0.1.10-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/6.5.0-41-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 930713d77a8f3d77333877c1d471626a70677c225ab379b96780917a4b631ece |
|
MD5 | 1c473c75994ae81a87b1a3f8ba909f69 |
|
BLAKE2b-256 | 6db6207f905c1455d7b950b68891e930807e73193fa31fcf6b41ee0a266d3a37 |