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.3.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.3.tar.gz.
File metadata
- Download URL: typer_tools-0.1.3.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 |
f447ef0961a27316b1e601a320f1540d7e344d8132899ef6b2b781e3e56c7aaa
|
|
| MD5 |
2368183237cfde9e15a746b4d1cdc34f
|
|
| BLAKE2b-256 |
a29df03d5b28eb7ec5b79cd2888786cbf6a480055acd148b023479963ef51257
|
File details
Details for the file typer_tools-0.1.3-py3-none-any.whl.
File metadata
- Download URL: typer_tools-0.1.3-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 |
05e5c3aa8ff28272dce2a8c4e91a7852660d0dd24cdbc90e70a7568a938cabec
|
|
| MD5 |
774b9d1ad422b3b52b4ac4a59534f66e
|
|
| BLAKE2b-256 |
bc99a724352b950d71961dcac47435c2f4b7de07b05168fa62563b5294bd1947
|