:memo: Fix typos, update docs and descriptions
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 5aa9bdd · Browse files · 4 files·+24 added−12 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+24 added−12 removed
- other:+24 added−12 removed
Provenance
- Commit
95c1f10- Tree
8a8d63e- Author
Sebastián Ramírez <tiangolo@gmail.com>- Committer
Sebastián Ramírez <tiangolo@gmail.com>- Parent
5aa9bdd
4 files changed+24 added−12 removed
modified:docs/tutorial/first-steps.md+21 added-9 removed
20 unmodified lines21 22 // Now check the --help23 $ python main.py --help24 25-Usage: tryit.py [OPTIONS]25+Usage: main.py [OPTIONS]26 27 Options:28 --install-completion Install completion for the current shell.29 --show-completion Show completion for the current shell, to copy it or customize the installation.143 unmodified lines173 </div>174 175 The main visual difference between a *CLI option* and and a *CLI argument* is that the *CLI option* has `--` prepended to the name, like in "`--size`".176 177-A *CLI option* doesn't depend on the order because it has a predefined name (here it's `--size`). This is because the CLI app is looking specifically for a literal `--size` parameter or "flag", with that specific "name" (here the specific name is "`--size`"). The CLI app will check if you typed it or not, it will be actively looking for `--size` even if you didn't type it (to check if it's there or not).177+A *CLI option* doesn't depend on the order because it has a predefined name (here it's `--size`). This is because the CLI app is looking specifically for a literal `--size` parameter (also known as "flag" or "switch"), with that specific "name" (here the specific name is "`--size`"). The CLI app will check if you typed it or not, it will be actively looking for `--size` even if you didn't type it (to check if it's there or not).178 179-In contrast, the CLI app is not actively looking for the *CLI argument* with a text "`./myproject`", it has no way to know if you would type `./myproject` or `./mysuperawesomeproject` or anything else. It's just waiting to get whatever you give it. The only way to know that you refer to a specific *CLI argument* is because of the order. The same way that it knows that the first *CLI argument* was the `name` and the second was the `lastname`, but if you mixed the order, it wouldn't be able to handle it.179+In contrast, the CLI app is not actively looking for the *CLI argument* with a text "`./myproject`", it has no way to know if you would type `./myproject` or `./my-super-awesome-project` or anything else. It's just waiting to get whatever you give it. The only way to know that you refer to a specific *CLI argument* is because of the order. The same way that it knows that the first *CLI argument* was the `name` and the second was the `lastname`, but if you mixed the order, it wouldn't be able to handle it.180 181 Instead, with a *CLI option*, the order doesn't matter.182 183 Also, by default, a *CLI option* is *optional* (not *required*).184 185+So, by default:186+187+* A *CLI argument* is **required**188+* A *CLI option* is **optional**189+190+But the *required* and *optional* defaults can be changed.191+192+So, the main and **most important** difference is that:193+194+* *CLI options* **start with `--`** and don't depend on the order195+* *CLI arguments* depend on the **sequence order**196+197 !!! tip186- In this example above the *CLI option* `--size` is just a "flag", it's a boolean value, `True` or `False`.198+ In this example above the *CLI option* `--size` is just a "flag" or "switch" that will contain a boolean value, `True` or `False`, depending on if it was added to the command or not.199 200 This one doesn't receive any values. But *CLI options* can also receive values like *CLI arguments*. You'll see how later.201 202 ## Add one *CLI option*127 unmodified lines330 331 ```console332 $ python main.py --help333 322-Usage: tutorial006.py [OPTIONS] NAME334+Usage: main.py [OPTIONS] NAME335 336 Say hi to NAME, optionally with a --lastname.337 338 If --formal is used, say hi very formally.66 unmodified lines405 And a parameter like `name`, that doesn't have a default value, is considered *required*.406 407 ### In CLIs408 397-When talking about command line interfaces/applications, the words "argument" and "parameter" are commonly used to refer to that data passed to a CLI app, those parameters.409+When talking about command line interfaces/applications, the words **"argument"** and **"parameter"** are commonly used to refer to that data passed to a CLI app, those parameters.410 399-But those words don't imply anything about the data being required, needing to be passed in a certain order, nor having a flag like `--lastname`.411+But those words **don't imply** anything about the data being required, needing to be passed in a certain order, nor having a flag like `--lastname`.412 401-The parameters that come with a flag like `--lastname` and a value (or when the flag itself is the value, like `--formal`) are commonly optional, not required. So, when talking about CLIs it's common to call them *optional arguments* or *optional parameters*.413+The parameters that come with a name like `--lastname` (and optionally a value) are commonly optional, not required. So, when talking about CLIs it's common to call them **optional arguments** or **optional parameters**. Sometimes these *optional parameters* that start with `--` are also called a **flag** or a **switch**.414 415 In reality, the parameters that require an order can be made *optional* too. And the ones that come with a flag (like `--lastname`) can be *required* too.416 417 ### In **Typer**1 unmodified line419 To try and make it a bit easier, we'll normally use the words "parameter" or "argument" to refer to Python functions.420 421 We'll use ***CLI argument*** to refer to those *CLI parameters* that depend on an order. That are **required** by default.422 411-And we'll use ***CLI option*** to refer to those *CLI parameters* that depend on a flag (like `--lastname`). That are **optional** by default.423+And we'll use ***CLI option*** to refer to those *CLI parameters* that depend on a name that starts with `--` (like `--lastname`). That are **optional** by default.424 425 We will use ***CLI parameter*** to refer to both, *CLI arguments* and *CLI options*.modified:docs/index.md+1 added-1 removed
96 unmodified lines97 --install-completion Install completion for the current shell.98 --show-completion Show completion for the current shell, to copy it or customize the installation.99 --help Show this message and exit.100 101-// You get a ✨ auto completion ✨ for free, installed with --install-completion101+// You get ✨ auto completion ✨ for free, installed with --install-completion102 103 // Now pass the NAME argument104 $ python main.py Camila105 169 unmodified linesmodified:docs/release-notes.md+1 added-1 removed
12345667891018 unmodified lines## Latest changes
## 0.0.5
* Clean exports from Typer. Remove unneeded components from Click and add needed `Exit` exception. PR [#11](https://github.com/tiangolo/typer/pull/11).* Fix and document extracting help from a functions' docstring [First Steps: Document your CLI app](https://typer.tiangolo.com/tutorial/first-steps/#document-your-cli-app). PR [#10](https://github.com/tiangolo/typer/pull/10).* Fix and document extracting help from a function's docstring [First Steps: Document your CLI app](https://typer.tiangolo.com/tutorial/first-steps/#document-your-cli-app). PR [#10](https://github.com/tiangolo/typer/pull/10).* Update references to `--install-completion` and `--show-completion` in docs. PR [#9](https://github.com/tiangolo/typer/pull/9).* Fix testing utilities, add tests for First Steps examples. PR [#8](https://github.com/tiangolo/typer/pull/8).* Add auto completion options by default when [click-completion](https://github.com/click-contrib/click-completion) is installed: `--install-completion` and `--show-completion`. PR [#7](https://github.com/tiangolo/typer/pull/7).* Update Termynal to have fixed sizes, add "fast" button, and use it in [First Steps](https://typer.tiangolo.com/tutorial/first-steps/). PR [#6](https://github.com/tiangolo/typer/pull/6).18 unmodified linesmodified:README.md+1 added-1 removed
96 unmodified lines97 --install-completion Install completion for the current shell.98 --show-completion Show completion for the current shell, to copy it or customize the installation.99 --help Show this message and exit.100 101-// You get a ✨ auto completion ✨ for free, installed with --install-completion101+// You get ✨ auto completion ✨ for free, installed with --install-completion102 103 // Now pass the NAME argument104 $ python main.py Camila105 169 unmodified lines