Skip to content

Commit 37cceb3

Browse files
committed
Merge branch 'master' into feat/pydantic
2 parents d89af29 + 9051baa commit 37cceb3

108 files changed

Lines changed: 979 additions & 1836 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,21 @@ The key features are:
4343

4444
## Installation
4545

46-
Create and activate a [virtual environment](https://typer.tiangolo.com/virtual-environments/) and then install **Typer**:
46+
First, [install `uv`](https://docs.astral.sh/uv/getting-started/installation/), and then add **Typer** to your project:
4747

4848
<div class="termy">
4949

5050
```console
51-
$ pip install typer
51+
$ uv add typer
5252
---> 100%
53-
Successfully installed typer rich shellingham
5453
```
5554

5655
</div>
5756

57+
This installs both the Typer library and the `typer` command in the project's virtual environment. To use `typer` directly with shell completion, [activate the project environment and install completion](tutorial/install.md#activate-the-virtual-environment).
58+
59+
If you prefer to use `pip`, install `typer` inside a virtual environment. See the [installation guide](tutorial/install.md) for the alternative steps.
60+
5861
## Example
5962

6063
### The absolute minimum
@@ -78,29 +81,29 @@ Run your application with the `typer` command:
7881
// Run your application
7982
$ typer main.py run
8083

81-
// You get a nice error, you are missing NAME
82-
Usage: typer [PATH_OR_MODULE] run [OPTIONS] NAME
84+
// You get a nice error, you are missing 'name'
85+
Usage: typer [PATH_OR_MODULE] run [OPTIONS] {name}
8386
Try 'typer [PATH_OR_MODULE] run --help' for help.
8487
╭─ Error ───────────────────────────────────────────╮
85-
│ Missing argument 'NAME'. │
88+
│ Missing argument 'name'. │
8689
╰───────────────────────────────────────────────────╯
8790

8891

8992
// You get a --help for free
9093
$ typer main.py run --help
9194

92-
Usage: typer [PATH_OR_MODULE] run [OPTIONS] NAME
95+
Usage: typer [PATH_OR_MODULE] run [OPTIONS] {name}
9396

9497
Run the provided Typer app.
9598

9699
╭─ Arguments ───────────────────────────────────────╮
97-
│ * name TEXT [default: None] [required] |
100+
│ * name <str> [required]
98101
╰───────────────────────────────────────────────────╯
99102
╭─ Options ─────────────────────────────────────────╮
100103
│ --help Show this message and exit. │
101104
╰───────────────────────────────────────────────────╯
102105

103-
// Now pass the NAME argument
106+
// Now pass the 'name' argument
104107
$ typer main.py run Camila
105108

106109
Hello Camila
@@ -136,30 +139,30 @@ Now you could run it with Python directly:
136139

137140
```console
138141
// Run your application
139-
$ python main.py
142+
$ uv run python main.py
140143

141-
// You get a nice error, you are missing NAME
142-
Usage: main.py [OPTIONS] NAME
144+
// You get a nice error, you are missing 'name'
145+
Usage: main.py [OPTIONS] {name}
143146
Try 'main.py --help' for help.
144147
╭─ Error ───────────────────────────────────────────╮
145-
│ Missing argument 'NAME'. │
148+
│ Missing argument 'name'. │
146149
╰───────────────────────────────────────────────────╯
147150

148151

149152
// You get a --help for free
150-
$ python main.py --help
153+
$ uv run python main.py --help
151154

152-
Usage: main.py [OPTIONS] NAME
155+
Usage: main.py [OPTIONS] {name}
153156

154157
╭─ Arguments ───────────────────────────────────────╮
155-
│ * name TEXT [default: None] [required] |
158+
│ * name <str> [required]
156159
╰───────────────────────────────────────────────────╯
157160
╭─ Options ─────────────────────────────────────────╮
158161
│ --help Show this message and exit. │
159162
╰───────────────────────────────────────────────────╯
160163

161-
// Now pass the NAME argument
162-
$ python main.py Camila
164+
// Now pass the 'name' argument
165+
$ uv run python main.py Camila
163166

164167
Hello Camila
165168

@@ -219,7 +222,7 @@ Check the new help:
219222
<div class="termy">
220223

221224
```console
222-
$ python main.py --help
225+
$ uv run python main.py --help
223226

224227
Usage: main.py [OPTIONS] COMMAND [ARGS]...
225228

@@ -236,13 +239,13 @@ $ python main.py --help
236239
│ and exit. │
237240
╰───────────────────────────────────────────────────╯
238241
╭─ Commands ────────────────────────────────────────╮
239-
│ goodbye │
240242
│ hello │
243+
│ goodbye │
241244
╰───────────────────────────────────────────────────╯
242245

243246
// When you create a package you get ✨ auto-completion ✨ for free, installed with --install-completion
244247

245-
// You have 2 subcommands (the 2 functions): goodbye and hello
248+
// You have 2 subcommands (the 2 functions): hello and goodbye
246249
```
247250

248251
</div>
@@ -252,12 +255,12 @@ Now check the help for the `hello` command:
252255
<div class="termy">
253256

254257
```console
255-
$ python main.py hello --help
258+
$ uv run python main.py hello --help
256259

257-
Usage: main.py hello [OPTIONS] NAME
260+
Usage: main.py hello [OPTIONS] {name}
258261

259262
╭─ Arguments ───────────────────────────────────────╮
260-
│ * name TEXT [default: None] [required] │
263+
│ * name <str> [required]
261264
╰───────────────────────────────────────────────────╯
262265
╭─ Options ─────────────────────────────────────────╮
263266
│ --help Show this message and exit. │
@@ -271,12 +274,12 @@ And now check the help for the `goodbye` command:
271274
<div class="termy">
272275

273276
```console
274-
$ python main.py goodbye --help
277+
$ uv run python main.py goodbye --help
275278

276-
Usage: main.py goodbye [OPTIONS] NAME
279+
Usage: main.py goodbye [OPTIONS] {name}
277280

278281
╭─ Arguments ───────────────────────────────────────╮
279-
│ * name TEXT [default: None] [required] │
282+
│ * name <str> [required]
280283
╰───────────────────────────────────────────────────╯
281284
╭─ Options ─────────────────────────────────────────╮
282285
│ --formal --no-formal [default: no-formal] │
@@ -296,19 +299,19 @@ Now you can try out the new command line application:
296299
```console
297300
// Use it with the hello command
298301

299-
$ python main.py hello Camila
302+
$ uv run python main.py hello Camila
300303

301304
Hello Camila
302305

303306
// And with the goodbye command
304307

305-
$ python main.py goodbye Camila
308+
$ uv run python main.py goodbye Camila
306309

307310
Bye Camila!
308311

309312
// And with --formal
310313

311-
$ python main.py goodbye --formal Camila
314+
$ uv run python main.py goodbye --formal Camila
312315

313316
Goodbye Ms. Camila. Have a good day.
314317
```

0 commit comments

Comments
 (0)