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 demp 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.4.tar.gz
(3.8 kB
view details)
Built Distribution
File details
Details for the file typer_shell-0.1.4.tar.gz
.
File metadata
- Download URL: typer_shell-0.1.4.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.6 Linux/5.19.0-41-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a2efbe11d79dac6d320ab9ed1351d793aa053cae266bec63638d85713fa65ec |
|
MD5 | 6576dcc1a0281b01c1b2015e1fc6b818 |
|
BLAKE2b-256 | 70c054b53e0d94a88bb86424935db00754daff987215dbb12a90807e2767690f |
File details
Details for the file typer_shell-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: typer_shell-0.1.4-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.6 Linux/5.19.0-41-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15c3e97c7a798c4e950e36cd30de1c1ad76cd6d54476fb66cde0b3e2dcef4d00 |
|
MD5 | d1bea61e89118c437c1cd9d498c21785 |
|
BLAKE2b-256 | 68e4535af81c2184bcb85f750babb1019872ddb39884e9dd378015ab43f37189 |