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.4.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.4.tar.gz.
File metadata
- Download URL: typer_tools-0.1.4.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 |
17cb9652479ee1aeeb26a1797210004478542b711f8d5e33d7cc0111673605df
|
|
| MD5 |
e1962ff5cd8da3ffac6b2d3ff6452f94
|
|
| BLAKE2b-256 |
eb1a9e4c85221683f4e805c368555d6f453a07ae8b41315f4fb7ca37d9ecd404
|
File details
Details for the file typer_tools-0.1.4-py3-none-any.whl.
File metadata
- Download URL: typer_tools-0.1.4-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 |
e695c4598dccffdb86e112dff186c659dfe14b37005d7bf419ef691434075edc
|
|
| MD5 |
6f843029b5fd2723b9139938989c6473
|
|
| BLAKE2b-256 |
71da264a5bad2a185dcee0df7ab5ce2512528144a965c82ceab0e7c86508d079
|