Skip to main content

Typer CLI

Easily run your Typer applications without installing them, using Typer CLI.

⚠️ WARNING: If you are building a CLI package you probably need Typer, the library itself. This, Typer CLI, is a CLI application that simplifies running simple Typer applications, it is not the library itself.

Description

Typer is a library for building CLIs (Command Line Interface applications).

Typer CLI is a CLI application that simplifies running simple programs created with Typer.

The main feature it does is provide completion for your own programs built with Typer without you having to install them locally as a package.

It's probably most useful if you have a small custom Python script using Typer that is part of some project, for some small tasks, and it's not complex/important enough to build a whole CLI package for it (something to be installed with pip).

In that case, you can install Typer CLI, and run your program with typer, and it will provide completion for your script.

Usage

Install Typer CLI:

$ python -m pip install typer-cli

That creates a typer command.

You can then install completion for it:

$ typer --install-completion

Then, let's say you have a script that uses Typer in my_custom_script.py:

import typer

app = typer.Typer()


@app.command()
def hello(name: str = None):
    if name:
        typer.echo(f"Hello {name}")
    else:
        typer.echo("Hello World!")


@app.command()
def bye(name: str = None):
    if name:
        typer.echo(f"Bye {name}")
    else:
        typer.echo("Goodbye!")


if __name__ == "__main__":
    app()

Then you could call it with normal Python:

$ python my_custom_script.py hello

Hello World!

$ python my_custom_script.py hello --name Camila

Hello Camila!

$ python my_custom_script.py bye --name Camila

Bye Camila

But you won't get completion in your terminal for any of the subcommands or options, like hello, bye, and --name.

Here's where Typer CLI is useful. You can also run it with the typer command you get after installing typer-cli:

$ typer my_custom_script.py run hello

Hello World!

$ typer my_custom_script.py run hello --name Camila

Hello Camila!

$ typer my_custom_script.py run bye --name Camila

Bye Camila

Instead of typing python, you type typer, and after the name of the file you add a run (that will be autocompleted with when you hit TAB) and it will give you completion for all the commands and options when you hit TAB.

If main

Because Typer CLI won't use the block with:

if __name__ == "__main__":
    app()

You can also remove it if you are calling that script only with Typer CLI (using the typer command).

Metadata

Release files for typer-cli 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for typer-cli 0.0.2
File Size Uploaded
typer-cli-0.0.2.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for typer-cli 0.0.2
File Interpreter ABI Platform
typer_cli-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 7.3 kB

Release files / typer-cli-0.0.2.tar.gz

Download URL typer-cli-0.0.2.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b63c67546650543b774515b0313462debddf3c3986319c0138ddbc401b3c3f30
BLAKE2b-256 checksum
How to use checksums
a237bf387608bd40d23e9c03f78232c03655ab621c1065137667fa3050a84db2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.3 CPython/3.6.9 Linux/4.15.0-74-generic

Release files / typer_cli-0.0.2-py3-none-any.whl

Download URL typer_cli-0.0.2-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8edcd2217683d81ab6fc772a9abad8f5383080a977ca237ad0a3263272cbfe99
BLAKE2b-256 checksum
How to use checksums
e7ada41e045d97f764f80aaa2535b7d8b59364ebf68591876d8912c64dd2b40d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.3 CPython/3.6.9 Linux/4.15.0-74-generic

Release history Release notifications | RSS feed

0.24.0

2 release files

0.23.2

2 release files

0.23.1

2 release files

0.23.0

2 release files

0.22.0

2 release files

0.21.2

2 release files

0.21.0

2 release files

0.20.1

2 release files

0.20.0

2 release files

0.19.2

2 release files

0.19.1

2 release files

0.19.0

2 release files

0.18.0

2 release files

0.17.5

2 release files

0.17.3

2 release files

0.17.2

2 release files

0.17.1

2 release files

0.17.0

2 release files

0.16.1

2 release files

0.16.0

2 release files

0.15.4

2 release files

0.15.3

2 release files

0.15.2

2 release files

0.14.0

2 release files

0.13.1

2 release files

0.12.5

2 release files

0.12.4

2 release files

0.12.0

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page