Simple tools for Typer CLI
Project description
Typer Tools
Simple tools for Typer CLI
pip install typer-tools
Options Anywhere
Typer does not support making cli -v export and cli export -v work the same way. But we can handle:
from typer_tools import option
Verbose = option(False, '-v', '--verbose') # drop-in replacement for typer.Option
@app.callback()
def main(verbose: bool = Verbose):
...
@app.command()
def export(verbose: bool = Verbose):
...
Dependency Injection
Typer does not support dependency injection. But we can handle:
from typer_tools import Dependency
def parse_client(
host: str = typer.Option(..., '--host', help='HTTP host'), # or our own `option`, plain better
port: int = typer.Option(80, '--port', help='HTTP port'),
token: str = typer.Option(..., '--token', help='Access token')
) -> Client:
...
dep = Dependency(parse_client)
@typer.command()
@dep.inject
def main(some_option: str, client: Client = dep.Depends()):
...
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_tools-0.1.6.tar.gz
(3.1 kB
view details)
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_tools-0.1.6.tar.gz.
File metadata
- Download URL: typer_tools-0.1.6.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa83428796b1d1a2a088ba478dfb6accc3c779d77f46ad3384e237866409a793
|
|
| MD5 |
663f9d4aea8f2e3b6883009c115a78a3
|
|
| BLAKE2b-256 |
422f5d051ea33489e860ccd151d7dec9909b57d3e4655fbaf4cfd9845954e7e2
|
File details
Details for the file typer_tools-0.1.6-py3-none-any.whl.
File metadata
- Download URL: typer_tools-0.1.6-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01ceb778eb03d8033697f5172d1de0a2deee41b5c1c7140ff2127118d974cde8
|
|
| MD5 |
d5d866a8c100c167788960a64e8bcd53
|
|
| BLAKE2b-256 |
fca2aee3b629c622cd32c993b3c8bdbd879a41b972329b0a94a6268e643326e7
|