Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
<em>Typer, build great CLIs. Easy to code. Based on Python type hints.</em>
</p>
<p align="center">
<a href="https://github.com/fastapi/typer/actions?query=workflow%3ATest+event%3Apush+branch%3Amaster" target="_blank">
<a href="https://github.com/fastapi/typer/actions?query=workflow%3ATest+event%3Apush+branch%3Amaster">
<img src="https://github.com/fastapi/typer/actions/workflows/test.yml/badge.svg?event=push&branch=master" alt="Test">
</a>
<a href="https://github.com/fastapi/typer/actions?query=workflow%3APublish" target="_blank">
<a href="https://github.com/fastapi/typer/actions?query=workflow%3APublish">
<img src="https://github.com/fastapi/typer/workflows/Publish/badge.svg" alt="Publish">
</a>
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/fastapi/typer" target="_blank">
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/fastapi/typer">
<img src="https://coverage-badge.samuelcolvin.workers.dev/fastapi/typer.svg" alt="Coverage">
<a href="https://pypi.org/project/typer" target="_blank">
<a href="https://pypi.org/project/typer">
<img src="https://img.shields.io/pypi/v/typer?color=%2334D058&label=pypi%20package" alt="Package version">
</a>
</p>

---

**Documentation**: <a href="https://typer.tiangolo.com" target="_blank">https://typer.tiangolo.com</a>
**Documentation**: [https://typer.tiangolo.com](https://typer.tiangolo.com)

**Source Code**: <a href="https://github.com/fastapi/typer" target="_blank">https://github.com/fastapi/typer</a>
**Source Code**: [https://github.com/fastapi/typer](https://github.com/fastapi/typer)

---

Expand All @@ -42,11 +42,11 @@ The key features are:

## FastAPI of CLIs

**Typer** is <a href="https://fastapi.tiangolo.com" class="external-link" target="_blank">FastAPI</a>'s little sibling, it's the FastAPI of CLIs.
**Typer** is [FastAPI](https://fastapi.tiangolo.com)'s little sibling, it's the FastAPI of CLIs.

## Installation

Create and activate a <a href="https://typer.tiangolo.com/virtual-environments/" class="external-link" target="_blank">virtual environment</a> and then install **Typer**:
Create and activate a [virtual environment](https://typer.tiangolo.com/virtual-environments/) and then install **Typer**:

<div class="termy">

Expand Down Expand Up @@ -354,9 +354,9 @@ For a more complete example including more features, see the <a href="https://ty

**Typer** stands on the shoulders of giants. It has three required dependencies:

* <a href="https://click.palletsprojects.com/" class="external-link" target="_blank">Click</a>: a popular tool for building CLIs in Python. Typer is based on it.
* <a href="https://rich.readthedocs.io/en/stable/index.html" class="external-link" target="_blank"><code>rich</code></a>: to show nicely formatted errors automatically.
* <a href="https://github.com/sarugaku/shellingham" class="external-link" target="_blank"><code>shellingham</code></a>: to automatically detect the current shell when installing completion.
* [Click](https://click.palletsprojects.com/): a popular tool for building CLIs in Python. Typer is based on it.
* [`rich`](https://rich.readthedocs.io/en/stable/index.html): to show nicely formatted errors automatically.
* [`shellingham`](https://github.com/sarugaku/shellingham): to automatically detect the current shell when installing completion.

### `typer-slim`

Expand Down
18 changes: 9 additions & 9 deletions docs/alternatives.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ There have been many tools created before that have helped inspire its creation.

## Previous tools

### <a href="https://docs.python.org/3/library/argparse.html" class="external-link" target="_blank">`argparse`</a>
### [`argparse`](https://docs.python.org/3/library/argparse.html)

`argparse` is the Python standard library's module to write CLIs.

Expand All @@ -22,7 +22,7 @@ Provide a better development experience than just reading *CLI Parameters* by ha

///

### <a href="https://hugapi.github.io/hug/" class="external-link" target="_blank">Hug</a>
### [Hug](https://hugapi.github.io/hug/)

Hug is a library to create APIs and CLIs, it uses parameters in functions to declare the required data.

Expand All @@ -34,7 +34,7 @@ Use function parameters to declare *CLI arguments* and *CLI options* as it simpl

///

### <a href="https://plac.readthedocs.io/en/latest/" class="external-link" target="_blank">Plac</a>
### [Plac](https://plac.readthedocs.io/en/latest/)

Plac is another library to create CLIs using parameters in functions, similar to Hug.

Expand All @@ -44,7 +44,7 @@ Provide a simple way to use a function as a command line app, without having to

///

### <a href="https://pydantic-docs.helpmanual.io/" class="external-link" target="_blank">Pydantic</a>
### [Pydantic](https://pydantic-docs.helpmanual.io/)

Pydantic is a library to handle data validation using standard modern Python type annotations.

Expand All @@ -58,7 +58,7 @@ Use standard Python type annotations to declare types instead of library-specifi

///

### <a href="https://click.palletsprojects.com" class="external-link" target="_blank">Click</a>
### [Click](https://click.palletsprojects.com)

Click is one of the most widely used libraries to create CLIs in Python.

Expand All @@ -76,11 +76,11 @@ Everything. πŸš€

**Typer** mainly adds a layer on top of Click, making the code simpler and easier to use, with autocompletion everywhere, etc, but providing all the powerful features of Click underneath.

As someone pointed out: <em><a href="https://twitter.com/fishnets88/status/1210126833745838080" class="external-link" target="_blank">"Nice to see it is built on Click but adds the type stuff. Me gusta!"</a></em>
As someone pointed out: <em>["Nice to see it is built on Click but adds the type stuff. Me gusta!"](https://twitter.com/fishnets88/status/1210126833745838080)</em>

///

### <a href="https://github.com/click-contrib/click-completion" class="external-link" target="_blank">`click-completion`</a>
### [`click-completion`](https://github.com/click-contrib/click-completion)

`click-completion` is a plug-in for Click. It was created to extend completion support for shells when Click only had support for Bash completion.

Expand All @@ -94,9 +94,9 @@ Provide auto completion for all the shells.

///

### <a href="https://fastapi.tiangolo.com/" class="external-link" target="_blank">FastAPI</a>
### [FastAPI](https://fastapi.tiangolo.com/)

I created **FastAPI** to provide an easy way to build APIs with autocompletion for everything in the code (and some other <a href="https://fastapi.tiangolo.com/features/" class="external-link" target="_blank">features</a>).
I created **FastAPI** to provide an easy way to build APIs with autocompletion for everything in the code (and some other [features](https://fastapi.tiangolo.com/features/)).

**Typer** is the "FastAPI of CLIs".

Expand Down
10 changes: 5 additions & 5 deletions docs/contributing.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Development - Contributing

First, you might want to see the basic ways to [help Typer and get help](help-typer.md){.internal-link target=_blank}.
First, you might want to see the basic ways to [help Typer and get help](help-typer.md).

## Developing

If you already cloned the <a href="https://github.com/fastapi/typer" class="external-link" target="_blank">typer repository</a> and you want to deep dive in the code, here are some guidelines to set up your environment.
If you already cloned the [typer repository](https://github.com/fastapi/typer) and you want to deep dive in the code, here are some guidelines to set up your environment.

### Install Requirements Using `uv`

Expand Down Expand Up @@ -253,7 +253,7 @@ $ mkdocs serve --dev-addr 8008

The instructions here show you how to use the script at `./scripts/docs.py` with the `python` program directly.

But you can also use <a href="https://typer.tiangolo.com/typer-cli/" class="external-link" target="_blank">Typer CLI</a>, and you will get autocompletion in your terminal for the commands after installing completion.
But you can also use [Typer CLI](https://typer.tiangolo.com/typer-cli/), and you will get autocompletion in your terminal for the commands after installing completion.

If you install Typer CLI, you can install completion with:

Expand All @@ -270,7 +270,7 @@ Completion will take effect once you restart the terminal.

### Docs Structure

The documentation uses <a href="https://www.mkdocs.org/" class="external-link" target="_blank">MkDocs</a>.
The documentation uses [MkDocs](https://www.mkdocs.org/).

And there are extra tools/scripts in place in `./scripts/docs.py`.

Expand Down Expand Up @@ -316,7 +316,7 @@ The same applies to comments and descriptions, please don't copy paste the conte

### Human Effort Denial of Service

Using automated tools and AI to submit PRs or comments that we have to carefully review and handle would be the equivalent of a <a href="https://en.wikipedia.org/wiki/Denial-of-service_attack" class="external-link" target="_blank">Denial-of-service attack</a> on our human effort.
Using automated tools and AI to submit PRs or comments that we have to carefully review and handle would be the equivalent of a [Denial-of-service attack](https://en.wikipedia.org/wiki/Denial-of-service_attack) on our human effort.

It would be very little effort from the person submitting the PR (an LLM prompt) that generates a large amount of effort on our side (carefully reviewing code).

Expand Down
10 changes: 5 additions & 5 deletions docs/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ print(f"Hello {name} from Python")

/// tip

The second argument to <a href="https://docs.python.org/3.8/library/os.html#os.getenv" class="external-link" target="_blank">`os.getenv()`</a> is the default value to return.
The second argument to [`os.getenv()`](https://docs.python.org/3.8/library/os.html#os.getenv) is the default value to return.

If not provided, it's `None` by default, here we provide `"World"` as the default value to use.

Expand Down Expand Up @@ -155,7 +155,7 @@ Hello World from Python

/// tip

You can read more about it at <a href="https://12factor.net/config" class="external-link" target="_blank">The Twelve-Factor App: Config</a>.
You can read more about it at [The Twelve-Factor App: Config](https://12factor.net/config).

///

Expand All @@ -165,7 +165,7 @@ These environment variables can only handle **text strings**, as they are extern

That means that **any value** read in Python from an environment variable **will be a `str`**, and any conversion to a different type or any validation has to be done in code.

You will learn more about using environment variables for your <abbr title="command line interface">CLI</abbr> applications later in the section about [CLI Arguments with Environment Variables](./tutorial/arguments/envvar.md){.internal-link target=_blank}.
You will learn more about using environment variables for your <abbr title="command line interface">CLI</abbr> applications later in the section about [CLI Arguments with Environment Variables](./tutorial/arguments/envvar.md).

## `PATH` Environment Variable

Expand Down Expand Up @@ -283,15 +283,15 @@ $ C:\opt\custompython\bin\python

////

This information will be useful when learning about [Virtual Environments](virtual-environments.md){.internal-link target=_blank}.
This information will be useful when learning about [Virtual Environments](virtual-environments.md).

It will also be useful when you **create your own CLI programs** as, for them to be available for your users, they will need to be somewhere in the `PATH` environment variable.

## Conclusion

With this you should have a basic understanding of what **environment variables** are and how to use them in Python.

You can also read more about them in the <a href="https://en.wikipedia.org/wiki/Environment_variable" class="external-link" target="_blank">Wikipedia for Environment Variable</a>.
You can also read more about them in the [Wikipedia for Environment Variable](https://en.wikipedia.org/wiki/Environment_variable).

In many cases it's not very obvious how environment variables would be useful and applicable right away. But they keep showing up in many different scenarios when you are developing, so it's good to know about them.

Expand Down
12 changes: 6 additions & 6 deletions docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

## Design based on **FastAPI**

<a href="https://fastapi.tiangolo.com" target="_blank"><img src="https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png" style="width: 20%;"></a>
<a href="https://fastapi.tiangolo.com"><img src="https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png" style="width: 20%;"></a>

**Typer** is <a href="https://fastapi.tiangolo.com" class="external-link" target="_blank">FastAPI</a>'s little sibling.
**Typer** is [FastAPI](https://fastapi.tiangolo.com)'s little sibling.

It follows the same design and ideas. If you know **FastAPI**, you already know **Typer**... more or less.

## Just Modern Python

It's all based on standard **Python type** declarations. No new syntax to learn. Just standard modern Python.

If you need a 2 minute refresher of how to use Python types (even if you don't use FastAPI or Typer), check the FastAPI tutorial section: <a href="https://fastapi.tiangolo.com/python-types/" class="external-link" target="_blank">Python types intro</a>.
If you need a 2 minute refresher of how to use Python types (even if you don't use FastAPI or Typer), check the FastAPI tutorial section: [Python types intro](https://fastapi.tiangolo.com/python-types/).

You will also see a 20 seconds refresher on the section [Tutorial - User Guide: First Steps](tutorial/first-steps.md){.internal-link target=_blank}.
You will also see a 20 seconds refresher on the section [Tutorial - User Guide: First Steps](tutorial/first-steps.md).

## Editor support

Expand All @@ -24,11 +24,11 @@ You will rarely need to come back to the docs.

Here's how your editor might help you:

* in <a href="https://code.visualstudio.com/" class="external-link" target="_blank">Visual Studio Code</a>:
* in [Visual Studio Code](https://code.visualstudio.com/):

![editor support](img/vscode-completion.png)

* in <a href="https://www.jetbrains.com/pycharm/" class="external-link" target="_blank">PyCharm</a>:
* in [PyCharm](https://www.jetbrains.com/pycharm/):

![editor support](img/pycharm-completion.png)

Expand Down
Loading