:memo: Update README.md from docs/index.md
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sebastián Ramírez · committed by Sebastián Ramírez · parent 0842c83 · Browse files · 1 file·+38 added−81 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+38 added−81 removed
- other:+38 added−81 removed
Provenance
- Commit
30c8e5f- Tree
bfff4fb- Author
Sebastián Ramírez <tiangolo@gmail.com>- Committer
Sebastián Ramírez <tiangolo@gmail.com>- Parent
0842c83
1 file changed+38 added−81 removed
modified:README.md+38 added-81 removed
42 unmodified lines43 Typer stands on the shoulders of a giant. Its only internal dependency is <a href="https://click.palletsprojects.com/" target="_blank">Click</a>.44 45 ## Installation46 47+<div class="termy">47-```bash48-pip install typer48+```console49+$ pip install typer50+---> 100%51+Successfully installed typer52 ```53+</div>54 55 ## Example56 57 ### The absolute minimum15 unmodified lines73 ### Run it74 75 Run your application:76 73-```bash74-python main.py75-```77+<div class="termy">78+```console79+// Run your application80+$ python main.py81 77-you will get a response like:78-79-```82+// You get a nice error, you are missing NAME83 Usage: main.py [OPTIONS] NAME84 Try "main.py --help" for help.85 86 Error: Missing argument "NAME".84-```87 86-Now pass the `NAME` *argument*:88+// You get a --help for free89+$ python main.py --help90 88-```bash89-python main.py Camila90-```91+Usage: main.py [OPTIONS] NAME92 92-You will get a response like:93+Options:94+ --help Show this message and exit.95 94-```96+// Now pass the NAME argument97+$ python main.py Camila98+99 Hello Camila96-```100 98-And you automatically get a `--help` command:99-100-```bash101-python main.py --help101+// It works! 🎉102 ```103+</div>104 104-shows:105-106-```107-Usage: main.py [OPTIONS] NAME108-109-Options:110- --help Show this message and exit.111-```112-105 ## Example upgrade106 107 This was the simplest example possible.108 36 unmodified lines145 * Execute the `app()` itself, as if it was a function (instead of `typer.run`).146 147 ### Run the upgraded example148 157-Get the main `--help`:149+<div class="termy">150+```console151+// Check the --help152+$ python main.py --help153 159-```bash160-python main.py --help161-```162-163-shows:164-165-```154 Usage: main.py [OPTIONS] COMMAND [ARGS]...155 156 Options:157 --help Show this message and exit.158 159 Commands:160 goodbye161 hello174-```162 176-You have 2 sub-commands (the 2 functions), `goodbye` and `hello`.163+// You have 2 sub-commands (the 2 functions): goodbye and hello164 178-Now get the help for `hello`:165+// Now get the --help for hello166 180-```bash181-python main.py hello --help167+$ python main.py hello --help182-```168 184-shows:185-186-```169 Usage: main.py hello [OPTIONS] NAME170 171 Options:172 --help Show this message and exit.191-```173 193-And now get the help for `goodbye`:174+// And now get the --help for goodbye175 195-```bash196-python main.py goodbye --help176+$ python main.py goodbye --help197-```177 199-shows:200-201-```178 Usage: main.py goodbye [OPTIONS] NAME179 180 Options:181 --formal / --no-formal182 --help Show this message and exit.207-```183 209-Notice how it automatically creates a `--formal` and `--no-formal` for your `bool` *option*.184+// Automatic --formal and --no-formal for the bool option 🎉185 211----186+// And if you use it with the hello command187 213-And of course, if you use it, it does what you expect:188+$ python main.py hello Camila189 215-```bash216-python main.py hello Camila217-```218-219-shows:220-221-```190 Hello Camila223-```191 225-Then:192+// And with the goodbye command193 227-```bash228-python main.py goodbye Camila194+$ python main.py goodbye Camila229-```195 231-shows:232-233-```196 Bye Camila!235-```197 237-And:198+// And with --formal199 239-```bash240-python main.py goodbye --formal Camila200+$ python main.py goodbye --formal Camila241-```201 243-shows:244-245-```202 Goodbye Ms. Camila. Have a good day.203 ```204+</div>205 206 ### Recap207 208 In summary, you declare **once** the types of parameters (*arguments* and *options*) as function parameters.54 unmodified lines