Skip to main content

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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

typer_tools-0.1.3-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

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

Hashes for typer_tools-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f447ef0961a27316b1e601a320f1540d7e344d8132899ef6b2b781e3e56c7aaa
MD5 2368183237cfde9e15a746b4d1cdc34f
BLAKE2b-256 a29df03d5b28eb7ec5b79cd2888786cbf6a480055acd148b023479963ef51257

See more details on using hashes here.

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

Hashes for typer_tools-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 05e5c3aa8ff28272dce2a8c4e91a7852660d0dd24cdbc90e70a7568a938cabec
MD5 774b9d1ad422b3b52b4ac4a59534f66e
BLAKE2b-256 bc99a724352b950d71961dcac47435c2f4b7de07b05168fa62563b5294bd1947

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page