Skip to content
Myr

:recycle: Refactor docs structure and add CLI option names

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 19a4f6e · Browse files · 85 files+2316 added−1648 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

85 files+2316 added−1648 removed

  • tests:+839 added−584 removed
  • other:+1477 added−1064 removed

85 files+2316 added−1648 removed

added:docs/src/commands/arguments/tutorial001.py+17 added
1import typer23app = typer.Typer()456@app.command()7def create(username: str):8 typer.echo(f"Creating user: {username}")91011@app.command()12def delete(username: str):13 typer.echo(f"Deleting user: {username}")141516if __name__ == "__main__":17 app()
added:docs/src/commands/help/tutorial001.py+62 added
1import typer23app = typer.Typer(help="Awesome CLI user manager.")456@app.command()7def create(username: str):8 """9 Create a new user with USERNAME.10 """11 typer.echo(f"Creating user: {username}")121314@app.command()15def delete(16 username: str,17 force: bool = typer.Option(18 ...,19 prompt="Are you sure you want to delete the user?",20 help="Force deletion without confirmation.",21 ),22):23 """24 Delete a user with USERNAME.2526 If --force is not used, will ask for confirmation.27 """28 if force:29 typer.echo(f"Deleting user: {username}")30 else:31 typer.echo("Operation cancelled")323334@app.command()35def delete_all(36 force: bool = typer.Option(37 ...,38 prompt="Are you sure you want to delete ALL users?",39 help="Force deletion without confirmation.",40 )41):42 """43 Delete ALL users in the database.4445 If --force is not used, will ask for confirmation.46 """47 if force:48 typer.echo("Deleting all users")49 else:50 typer.echo("Operation cancelled")515253@app.command()54def init():55 """56 Initialize the users database.57 """58 typer.echo("Initializing user database")596061if __name__ == "__main__":62 app()
added:docs/src/commands/help/tutorial002.py+23 added
1import typer23app = typer.Typer()456@app.command(help="Create a new user with USERNAME.")7def create(username: str):8 """9 Some internal utility function to create.10 """11 typer.echo(f"Creating user: {username}")121314@app.command(help="Delete a user with USERNAME.")15def delete(username: str):16 """17 Some internal utility function to delete.18 """19 typer.echo(f"Deleting user: {username}")202122if __name__ == "__main__":23 app()
added:docs/src/commands/index/tutorial001.py+12 added
1import typer23app = typer.Typer()456@app.command()7def main(name: str):8 typer.echo(f"Hello {name}")91011if __name__ == "__main__":12 app()
added:docs/src/commands/index/tutorial002.py+17 added
1import typer23app = typer.Typer()456@app.command()7def create():8 typer.echo("Creating user: Hiro Hamada")91011@app.command()12def delete():13 typer.echo("Deleting user: Hiro Hamada")141516if __name__ == "__main__":17 app()
added:docs/src/commands/name/tutorial001.py+17 added
1import typer23app = typer.Typer()456@app.command("create")7def cli_create_user(username: str):8 typer.echo(f"Creating user: {username}")91011@app.command("delete")12def cli_delete_user(username: str):13 typer.echo(f"Deleting user: {username}")141516if __name__ == "__main__":17 app()
added:docs/src/commands/options/tutorial001.py+38 added
1import typer23app = typer.Typer()456@app.command()7def create(username: str):8 typer.echo(f"Creating user: {username}")91011@app.command()12def delete(13 username: str,14 force: bool = typer.Option(..., prompt="Are you sure you want to delete the user?"),15):16 if force:17 typer.echo(f"Deleting user: {username}")18 else:19 typer.echo("Operation cancelled")202122@app.command()23def delete_all(24 force: bool = typer.Option(..., prompt="Are you sure you want to delete ALL users?")25):26 if force:27 typer.echo("Deleting all users")28 else:29 typer.echo("Operation cancelled")303132@app.command()33def init():34 typer.echo("Initializing user database")353637if __name__ == "__main__":38 app()
deleted:docs/src/commands/tutorial001.py-12 removed
1import typer23app = typer.Typer()456@app.command()7def main(name: str):8 typer.echo(f"Hello {name}")91011if __name__ == "__main__":12 app()
deleted:docs/src/commands/tutorial002.py-17 removed
1import typer23app = typer.Typer()456@app.command()7def create():8 typer.echo("Creating user: Hiro Hamada")91011@app.command()12def delete():13 typer.echo("Deleting user: Hiro Hamada")141516if __name__ == "__main__":17 app()
deleted:docs/src/commands/tutorial003.py-17 removed
1import typer23app = typer.Typer()456@app.command()7def create(username: str):8 typer.echo(f"Creating user: {username}")91011@app.command()12def delete(username: str):13 typer.echo(f"Deleting user: {username}")141516if __name__ == "__main__":17 app()
deleted:docs/src/commands/tutorial004.py-38 removed
1import typer23app = typer.Typer()456@app.command()7def create(username: str):8 typer.echo(f"Creating user: {username}")91011@app.command()12def delete(13 username: str,14 force: bool = typer.Option(..., prompt="Are you sure you want to delete the user?"),15):16 if force:17 typer.echo(f"Deleting user: {username}")18 else:19 typer.echo("Operation cancelled")202122@app.command()23def delete_all(24 force: bool = typer.Option(..., prompt="Are you sure you want to delete ALL users?")25):26 if force:27 typer.echo("Deleting all users")28 else:29 typer.echo("Operation cancelled")303132@app.command()33def init():34 typer.echo("Initializing user database")353637if __name__ == "__main__":38 app()
deleted:docs/src/commands/tutorial005.py-62 removed
1import typer23app = typer.Typer(help="Awesome CLI user manager.")456@app.command()7def create(username: str):8 """9 Create a new user with USERNAME.10 """11 typer.echo(f"Creating user: {username}")121314@app.command()15def delete(16 username: str,17 force: bool = typer.Option(18 ...,19 prompt="Are you sure you want to delete the user?",20 help="Force deletion without confirmation.",21 ),22):23 """24 Delete a user with USERNAME.2526 If --force is not used, will ask for confirmation.27 """28 if force:29 typer.echo(f"Deleting user: {username}")30 else:31 typer.echo("Operation cancelled")323334@app.command()35def delete_all(36 force: bool = typer.Option(37 ...,38 prompt="Are you sure you want to delete ALL users?",39 help="Force deletion without confirmation.",40 )41):42 """43 Delete ALL users in the database.4445 If --force is not used, will ask for confirmation.46 """47 if force:48 typer.echo("Deleting all users")49 else:50 typer.echo("Operation cancelled")515253@app.command()54def init():55 """56 Initialize the users database.57 """58 typer.echo("Initializing user database")596061if __name__ == "__main__":62 app()
deleted:docs/src/commands/tutorial006.py-17 removed
1import typer23app = typer.Typer()456@app.command("create")7def cli_create_user(username: str):8 typer.echo(f"Creating user: {username}")91011@app.command("delete")12def cli_delete_user(username: str):13 typer.echo(f"Deleting user: {username}")141516if __name__ == "__main__":17 app()
added:docs/src/options/help/tutorial001.py+21 added
1import typer234def main(5 name: str,6 lastname: str = typer.Option("", help="Last name of person to greet."),7 formal: bool = typer.Option(False, help="Say hi formally."),8):9 """10 Say hi to NAME, optionally with a --lastname.1112 If --formal is used, say hi very formally.13 """14 if formal:15 typer.echo(f"Good day Ms. {name} {lastname}.")16 else:17 typer.echo(f"Hello {name} {lastname}")181920if __name__ == "__main__":21 typer.run(main)
added:docs/src/options/help/tutorial002.py+9 added
1import typer234def main(fullname: str = typer.Option("Wade Wilson", show_default=True)):5 typer.echo(f"Hello {fullname}")678if __name__ == "__main__":9 typer.run(main)
added:docs/src/options/name/tutorial001.py+9 added
1import typer234def main(user_name: str = typer.Option(..., "--name")):5 typer.echo(f"Hello {user_name}")678if __name__ == "__main__":9 typer.run(main)
added:docs/src/options/name/tutorial002.py+9 added
1import typer234def main(user_name: str = typer.Option(..., "--name", "-n")):5 typer.echo(f"Hello {user_name}")678if __name__ == "__main__":9 typer.run(main)
added:docs/src/options/name/tutorial003.py+9 added
1import typer234def main(user_name: str = typer.Option(..., "-n")):5 typer.echo(f"Hello {user_name}")678if __name__ == "__main__":9 typer.run(main)
added:docs/src/options/name/tutorial004.py+9 added
1import typer234def main(user_name: str = typer.Option(..., "--user-name", "-n")):5 typer.echo(f"Hello {user_name}")678if __name__ == "__main__":9 typer.run(main)
added:docs/src/options/name/tutorial005.py+15 added
1import typer234def main(5 name: str = typer.Option(..., "--name", "-n"),6 formal: bool = typer.Option(False, "--formal", "-f"),7):8 if formal:9 typer.echo(f"Good day Ms. {name}.")10 else:11 typer.echo(f"Hello {name}")121314if __name__ == "__main__":15 typer.run(main)
added:docs/src/options/prompt/tutorial001.py+9 added
1import typer234def main(name: str, lastname: str = typer.Option(..., prompt=True)):5 typer.echo(f"Hello {name} {lastname}")678if __name__ == "__main__":9 typer.run(main)
added:docs/src/options/prompt/tutorial002.py+12 added
1import typer234def main(5 name: str,6 lastname: str = typer.Option(..., prompt="Please tell me your last name"),7):8 typer.echo(f"Hello {name} {lastname}")91011if __name__ == "__main__":12 typer.run(main)
added:docs/src/options/prompt/tutorial003.py+9 added
1import typer234def main(project_name: str = typer.Option(..., prompt=True, confirmation_prompt=True)):5 typer.echo(f"Deleting project {project_name}")678if __name__ == "__main__":9 typer.run(main)
added:docs/src/options/required/tutorial001.py+9 added
1import typer234def main(name: str, lastname: str = typer.Option(...)):5 typer.echo(f"Hello {name} {lastname}")678if __name__ == "__main__":9 typer.run(main)
deleted:docs/src/options/tutorial001.py-21 removed
1import typer234def main(5 name: str,6 lastname: str = typer.Option("", help="Last name of person to greet."),7 formal: bool = typer.Option(False, help="Say hi formally."),8):9 """10 Say hi to NAME, optionally with a --lastname.1112 If --formal is used, say hi very formally.13 """14 if formal:15 typer.echo(f"Good day Ms. {name} {lastname}.")16 else:17 typer.echo(f"Hello {name} {lastname}")181920if __name__ == "__main__":21 typer.run(main)
deleted:docs/src/options/tutorial002.py-9 removed
1import typer234def main(name: str, lastname: str = typer.Option(...)):5 typer.echo(f"Hello {name} {lastname}")678if __name__ == "__main__":9 typer.run(main)
deleted:docs/src/options/tutorial003.py-9 removed
1import typer234def main(name: str, lastname: str = typer.Option(..., prompt=True)):5 typer.echo(f"Hello {name} {lastname}")678if __name__ == "__main__":9 typer.run(main)
deleted:docs/src/options/tutorial004.py-12 removed
1import typer234def main(5 name: str,6 lastname: str = typer.Option(..., prompt="Please tell me your last name"),7):8 typer.echo(f"Hello {name} {lastname}")91011if __name__ == "__main__":12 typer.run(main)
deleted:docs/src/options/tutorial005.py-9 removed
1import typer234def main(project_name: str = typer.Option(..., prompt=True, confirmation_prompt=True)):5 typer.echo(f"Deleting project {project_name}")678if __name__ == "__main__":9 typer.run(main)
deleted:docs/src/options/tutorial006.py-9 removed
1import typer234def main(fullname: str = typer.Option("Wade Wilson", show_default=True)):5 typer.echo(f"Hello {fullname}")678if __name__ == "__main__":9 typer.run(main)
added:docs/tutorial/commands/arguments.md+39 added
1The same way as with a CLI application with a single command, subcommands (or just "commands") can also have their own *CLI arguments*:23```Python hl_lines="7 12"4{!./src/commands/arguments/tutorial001.py!}5```67<div class="termy">89```console10// Check the help for create11$ python main.py create --help1213Usage: main.py create [OPTIONS] USERNAME1415Options:16 --help Show this message and exit.1718// Call it with a CLI argument19$ python main.py create Camila2021Creating user: Camila2223// The same for delete24$ python main.py delete Camila2526Deleting user: Camila27```2829</div>3031!!! tip32 Everything to the *right* of the *command* are *CLI parameters* (*CLI arguments* and *CLI options*) for that command.3334!!! note "Technical Details"35 Actually, it's everything to the right of that command, *before any subcommand*.3637 It's possible to have groups of *subcommands*, it's like if one *command* also had *subcommands*. And then those *subcommands* could have their own *CLI parameters*, taking their own *CLI parameters*.3839 You will see about them later in another section.
added:docs/tutorial/commands/help.md+120 added
1The same as before, you can add help for the commands in the docstrings and the *CLI options*.23And the `typer.Typer()` application receives a parameter `help` that you can pass with the main help text for your CLI program:45```Python hl_lines="3 8 9 10 20 23 24 25 26 27 39 42 43 44 45 46 55 56 57"6{!./src/commands/help/tutorial001.py!}7```89Check it:1011<div class="termy">1213```console14// Check the new help15$ python main.py --help1617Usage: main.py [OPTIONS] COMMAND [ARGS]...1819 Awesome CLI user manager.2021Options:22 --install-completion Install completion for the current shell.23 --show-completion Show completion for the current shell, to copy it or customize the installation.24 --help Show this message and exit.2526Commands:27 create Create a new user with USERNAME.28 delete Delete a user with USERNAME.29 delete-all Delete ALL users in the database.30 init Initialize the users database.3132// Now the commands have inline help 🎉3334// Check the help for create35$ python main.py create --help3637Usage: main.py create [OPTIONS] USERNAME3839 Create a new user with USERNAME.4041Options:42 --help Show this message and exit.4344// Check the help for delete45$ python main.py delete --help4647Usage: main.py delete [OPTIONS] USERNAME4849 Delete a user with USERNAME.5051 If --force is not used, will ask for confirmation.5253Options:54 --force / --no-force Force deletion without confirmation. [required]55 --help Show this message and exit.5657// Check the help for delete-all58$ python main.py delete-all --help5960Usage: main.py delete-all [OPTIONS]6162 Delete ALL users in the database.6364 If --force is not used, will ask for confirmation.6566Options:67 --force / --no-force Force deletion without confirmation. [required]68 --help Show this message and exit.6970// Check the help for init71$ python main.py init --help7273Usage: main.py init [OPTIONS]7475 Initialize the users database.7677Options:78 --help Show this message and exit.79```8081</div>8283!!! tip84 `typer.Typer()` receives several other parameters for other things, we'll see that later.8586 You will also see how to use "Callbacks" later, and those include a way to add this same help message in a function docstring.8788## Overwrite command help8990You will probably be better adding the help text as a docstring to your functions, but if for some reason you wanted to overwrite it, you can use the `help` function argument passed to `@app.command()`:9192```Python hl_lines="6 14"93{!./src/commands/help/tutorial002.py!}94```9596Check it:9798<div class="termy">99100```console101// Check the help102$ python main.py --help103104// Notice it uses the help passed to @app.command()105Usage: main.py [OPTIONS] COMMAND [ARGS]...106107Options:108 --install-completion Install completion for the current shell.109 --show-completion Show completion for the current shell, to copy110 it or customize the installation.111 --help Show this message and exit.112113Commands:114 create Create a new user with USERNAME.115 delete Delete a user with USERNAME.116117// It uses "Create a new user with USERNAME." instead of "Some internal utility function to create."118```119120</div>
added:docs/tutorial/commands/index.md+182 added
1We have seen how to create a CLI program with possibly several *CLI Options* and *CLI Arguments*.23But **Typer** allows you to create CLI programs with several commands (also known as subcommands).45For example, the program `git` has several commands.67One command of `git` is `git push`. And `git push` in turn takes its own *CLI arguments* and *CLI options*.89For example:1011<div class="termy">1213```console14// The push command with no parameters15$ git push1617---> 100%1819// The push command with one CLI option --set-upstream and 2 CLI arguments20$ git push --set-upstream origin master2122---> 100%23```2425</div>2627Another command of `git` is `git pull`, it also has some *CLI parameters*.2829It's like if the same big program `git` had several small programs inside.3031!!! tip32 A command looks the same as a *CLI argument*, it's just some name without a preceding `--`. But commands have predefined name, and are used to group different sets of functionalities into the same CLI application.3334## Command or subcommand3536It's common to call a CLI program a "command".3738But when one of these programs have subcommands, those subcommands are also frequently called just "commands".3940Have that in mind so you don't get confused.4142Here I'll use **CLI application** or **program** to refer to the program you are building in Python with Typer, and **command** to refer to one of these "subcommands" of your program.4344## Explicit application4546Before creating CLI applications with multiple commands/subcommands we need to understand how to create an explicit `typer.Typer()` application.4748In the *CLI Options* and *CLI Argument* tutorials you have seen how to create a single function and then pass that function to `typer.run()`.4950For example:5152```Python hl_lines="9"53{!./src/first_steps/tutorial002.py!}54```5556But that is actually a shortcut. Under the hood, **Typer** converts that to a CLI application with `typer.Typer()` and executes it. All that inside of `typer.run()`.5758There's also a more explicit way to achieve the same:5960```Python hl_lines="3 6 12"61{!./src/commands/index/tutorial001.py!}62```6364When you use `typer.run()`, **Typer** is doing more or less the same as above, it will:6566* Create a new `typer.Typer()` "application".67* Create a new "`command`" with your function.68* Call the same "application" as if it was a function with "`app()`".6970!!! info "`@decorator` Info"71 That `@something` syntax in Python is called a "decorator".7273 You put it on top of a function. Like a pretty decorative hat (I guess that's where the term came from).7475 A "decorator" takes the function below and does something with it.7677 In our case, this decorator tells **Typer** that the function below is a "`command`".7879Both ways, with `typer.run()` and creating the explicit application, achieve the same.8081!!! tip82 If your use case is solved with just `typer.run()`, that's fine, you don't have to create the explicit `app` and use `@app.command()`, etc.8384 You might want to do that later when your app needs the extra features, but if it doesn't need them yet, that's fine.8586If you run the second example, with the explicit `app`, it works exactly the same:8788<div class="termy">8990```console91// Without a CLI argument92$ python main.py9394Usage: main.py [OPTIONS] NAME95Try "main.py --help" for help.9697Error: Missing argument "NAME".9899// With the NAME CLI argument100$ python main.py Camila101102Hello Camila103104// Asking for help105$ python main.py --help106107Usage: main.py [OPTIONS] NAME108109Options:110 --install-completion Install completion for the current shell.111 --show-completion Show completion for the current shell, to copy it or customize the installation.112 --help Show this message and exit.113```114115</div>116117## A CLI application with multiple commands118119Coming back to the CLI applications with multiple commands/subcommands, **Typer** allows creating CLI applications with multiple of them.120121Now that you know how to create an explicit `typer.Typer()` application and add one command, let's see how to add multiple commands.122123Let's say that we have a CLI application to manage users.124125We'll have a command to `create` users and another command to `delete` them.126127To begin, let's say it can only create and delete one single predefined user:128129```Python hl_lines="6 11"130{!./src/commands/index/tutorial002.py!}131```132133Now we have a CLI application with 2 commands, `create` and `delete`:134135<div class="termy">136137```console138// Check the help139$ python main.py --help140141Usage: main.py [OPTIONS] COMMAND [ARGS]...142143Options:144 --install-completion Install completion for the current shell.145 --show-completion Show completion for the current shell, to copy it or customize the installation.146 --help Show this message and exit.147148Commands:149 create150 delete151152// Test them153$ python main.py create154155Creating user: Hiro Hamada156157$ python main.py delete158159Deleting user: Hiro Hamada160161// Now we have 2 commands! 🎉162```163164</div>165166Notice that the help text now shows the 2 commands: `create` and `delete`.167168!!! tip169 By default, the names of the commands are generated from the function name.170171## Decorator Technical Details172173When you use `@app.command()` the function under the decorator is registered in the **Typer** application and is then used later by the application.174175But Typer doesn't modify that function itself, the function is left as is.176177That means that if your function is simple enough that you could create it without using `typer.Option()` or `typer.Argument()`, you could use the same function for a **Typer** application and a **FastAPI** application putting both decorators on top, or similar tricks.178179!!! note "Click Technical Details"180 This behavior is a design difference with Click.181182 In Click, when you add a `@click.command()` decorator it actually modifies the function underneath and replaces it with an object.
added:docs/tutorial/commands/name.md+46 added
1By default, the command names are generated from the function name.23So, if your function is something like:45```Python6def create(username: str):7 ...8```910Then the command name will be `create`.1112But if you already had a function called `create()` somewhere in your code, you would have to name your CLI function differently.1314And what if you wanted the command to still be named `create`?1516For this, you can set the name of the command in the first parameter for the `@app.command()` decorator:1718```Python hl_lines="6 11"19{!./src/commands/name/tutorial001.py!}20```2122Now, even though the functions are named `cli_create_user()` and `cli_delete_user()`, the commands will still be named `create` and `delete`:2324<div class="termy">2526```console27$ python main.py --help2829Usage: main.py [OPTIONS] COMMAND [ARGS]...3031Options:32 --install-completion Install completion for the current shell.33 --show-completion Show completion for the current shell, to copy it or customize the installation.34 --help Show this message and exit.3536Commands:37 create38 delete3940// Test it41$ python main.py create Camila4243Creating user: Camila44```4546</div>
added:docs/tutorial/commands/one-or-multiple.md+91 added
1You might have noticed that if you create a single command, as in the first example:23```Python hl_lines="3 6 12"4{!./src/commands/tutorial001.py!}5```67**Typer** is smart enough to create a CLI application with that single function as the main CLI application, not as a command/subcommand:89<div class="termy">1011```console12// Without a CLI argument13$ python main.py1415Usage: main.py [OPTIONS] NAME16Try "main.py --help" for help.1718Error: Missing argument "NAME".1920// With the NAME CLI argument21$ python main.py Camila2223Hello Camila2425// Asking for help26$ python main.py2728Usage: main.py [OPTIONS] NAME2930Options:31 --install-completion Install completion for the current shell.32 --show-completion Show completion for the current shell, to copy it or customize the installation.33 --help Show this message and exit.34```3536</div>3738!!! tip39 Notice that it doesn't show a command `main`, even though the function name is `main`.4041But if you add multiple commands, **Typer** will create one *CLI command* for each one of them:4243```Python hl_lines="6 11"44{!./src/commands/tutorial002.py!}45```4647Here we have 2 commands `create` and `delete`:4849<div class="termy">5051```console52// Check the help53$ python main.py --help5455Usage: main.py [OPTIONS] COMMAND [ARGS]...5657Options:58 --install-completion Install completion for the current shell.59 --show-completion Show completion for the current shell, to copy it or customize the installation.60 --help Show this message and exit.6162Commands:63 create64 delete6566// Test the commands67$ python main.py create6869Creating user: Hiro Hamada7071$ python main.py delete7273Deleting user: Hiro Hamada74```7576</div>7778!!! tip79 This is **Typer**'s behavior by default, but you could still create a CLI application with one single command, like:8081 ```82 $ python main.py main83 ```8485 instead of just:8687 ```88 $ python main.py89 ```9091 You will learn more about this in the section about application Callbacks.
added:docs/tutorial/commands/options.md+96 added
1Commands can also have their own *CLI options*.23In fact, each command can have different *CLI arguments* and *CLI options*:45```Python hl_lines="7 13 14 24 33"6{!./src/commands/options/tutorial001.py!}7```89Here we have multiple commands, with different *CLI parameters*:1011* `create`:12 * `username`: a *CLI argument*.13* `delete`:14 * `username`: a *CLI argument*.15 * `--force`: a *CLI option*, if not provided, it's prompted.16* `delete-all`:17 * `--force`: a *CLI option*, if not provided, it's prompted.18* `init`:19 * Doesn't take any *CLI parameters*.2021<div class="termy">2223```console24// Check the help25python main.py --help2627Usage: main.py [OPTIONS] COMMAND [ARGS]...2829Options:30 --install-completion Install completion for the current shell.31 --show-completion Show completion for the current shell, to copy it or customize the installation.32 --help Show this message and exit.3334Commands:35 create36 delete37 delete-all38 info39```4041</div>4243!!! tip44 Check the command `delete-all`, by default command names are generated from the function name, replacing `_` with `-`.4546Test it:4748<div class="termy">4950```console51// Check the command create52$ python main.py create Camila5354Creating user: Camila5556// Now test the command delete57$ python main.py delete Camila5859# Are you sure you want to delete the user? [y/N]: $ y6061Deleting user: Camila6263$ python main.py delete Wade6465# Are you sure you want to delete the user? [y/N]: $ n6667Operation cancelled6869// And finally, the command delete-all70// Notice it doesn't have CLI arguments, only a CLI option7172$ python main.py delete-all7374# Are you sure you want to delete ALL users? [y/N]: $ y7576Deleting all users7778$ python main.py delete-all7980# Are you sure you want to delete ALL users? [y/N]: $ n8182Operation cancelled8384// And if you pass the --force CLI option, it doesn't need to confirm8586$ python main.py delete-all --force8788Deleting all users8990// And init that doesn't take any CLI parameter91$ python main.py init9293Initializing user database94```9596</div>
added:docs/tutorial/options/help.md+100 added
1In the *First Steps* section you saw how to add help for a CLI app/command by adding it to a function's <abbr title="a multi-line string as the first expression inside a function (not assigned to any variable) used for documentation">docstring</abbr>.23Here's how that last example looked like:45```Python6{!./src/first_steps/tutorial006.py!}7```89Now we'll add a *help* section to the *CLI options*:1011```Python hl_lines="6 7"12{!./src/options/help/tutorial001.py!}13```1415We are replacing the default values we had before with `typer.Option()`.1617As we no longer have a default value there, the first parameter to `typer.Option()` serves the same purpose of defining that default value.1819So, if we had:2021```Python22lastname: str = ""23```2425now we write:2627```Python28lastname: str = typer.Option("")29```3031And both forms achieve the same: a *CLI option* with a default value of an empty string (`""`).3233And then we can pass the `help` keyword parameter:3435```Python36lastname: str = typer.Option("", help="this option does this and that")37```3839to create the help for that *CLI option*.4041Copy that example from above to a file `main.py`.4243Test it:4445<div class="termy">4647```console48$ python main.py --help4950Usage: main.py [OPTIONS] NAME5152 Say hi to NAME, optionally with a --lastname.5354 If --formal is used, say hi very formally.5556Options:57 --lastname TEXT Last name of person to greet.58 --formal / --no-formal Say hi formally.59 --install-completion Install completion for the current shell.60 --show-completion Show completion for the current shell, to copy it or customize the installation.61 --help Show this message and exit.6263// Now you have a help text for the --lastname and --formal CLI options 🎉64```6566</div>6768## Show default in help6970You can tell Typer to show the default value in the help text with `show_default=True`:7172```Python hl_lines="4"73{!./src/options/help/tutorial002.py!}74```7576And it will show up in the help text:7778<div class="termy">7980```console81$ python main.py8283Hello Wade Wilson8485// Show the help86$ python main.py --help8788Usage: main.py [OPTIONS]8990Options:91 --fullname TEXT [default: Wade Wilson]92 --install-completion Install completion for the current shell.93 --show-completion Show completion for the current shell, to copy it or customize the installation.94 --help Show this message and exit.95```9697</div>9899!!! tip100 Notice the `[default: Wade Wilson]` in the help text.
added:docs/tutorial/options/index.md+3 added
1In the next short sections we will see how to modify *CLI options* using `typer.Option()`.23`typer.Option()` works very similarly to `typer.Argument()`, but has some extra features that we'll see next.
added:docs/tutorial/options/name.md+328 added
1By default **Typer** will create a *CLI option* name from the function parameter.23So, if you have a function with:45```Python6def main(user_name: str = None):7 pass8```910or1112```Python13def main(user_name: str = typer.Option(None)):14 pass15```1617**Typer** will create a *CLI option*:1819```20--user-name21```2223But you can customize it if you want to.2425Let's say the function parameter name is `user_name` as above, but you want the *CLI option* to be just `--name`.2627You can pass the *CLI option* name that you want to have in the next positional argument passed to `typer.Option()`:2829```Python hl_lines="4"30{!./src/options/name/tutorial001.py!}31```3233Here you are passing the string `"--name"` as the second positional argument to `typer.Option()`.3435!!! info36 "<a href="https://docs.python.org/3.8/glossary.html#term-argument" target="_blank">Positional</a>" means that it's not a function argument with a keyword name.37 38 For example `show_default=True` is a keyword argument. "`show_default`" is the keyword.3940 But in `"--name"` there's no `option_name="--name"` or something similar, it's just the string value `"--name"` that goes in `typer.Option()` after the `...` value passed in the first position.4142 That's a "positional argument" in a function.4344Check it:4546<div class="termy">4748```console49$ python main.py --help5051// Notice the --name instead of --user-name52Usage: main.py [OPTIONS]5354Options:55 --name TEXT [required]56 --install-completion Install completion for the current shell.57 --show-completion Show completion for the current shell, to copy it or customize the installation.58 --help Show this message and exit.5960// Try it61$ python --name Camila6263Hello Camila64```6566</div>6768## *CLI option* short names6970A short name is a *CLI option* name with a single dash (`-`) instead of 2 (`--`) and a single letter, like `-n` instead of `--name`.7172For example, the `ls` program has a *CLI option* named `--size`, and the same *CLI option* also has a short name `-s`:7374<div class="termy">7576```console77// With the long name --size78$ ls ./myproject --size798012 first-steps.md 4 intro.md8182// With the short name -s83$ ls ./myproject -s848512 first-steps.md 4 intro.md8687// Both CLI option names do the same88```8990</div>9192### *CLI option* short names together9394Short names have another feature, when they have a single letter, as in `-s`, you can put several of these *CLI options* together, with a single dash.9596For example, the `ls` program has these 2 *CLI options* (among others):9798* `--size`: show the sizes of the listed files.99* `--human`: show a human-readable format, like `1MB` instead of just `1024`.100101And these 2 *CLI options* have short versions too:102103* `--size`: short version `-s`.104* `--human`: short version `-h`.105106So, you can put them together with `-sh` or `-hs`:107108<div class="termy">109110```console111// Call ls with long CLI options112$ ls --size --human11311412K first-steps.md 4.0K intro.md115116// Now with short versions117$ ls -s -h11811912K first-steps.md 4.0K intro.md120121// And with short versions together122$ ls -sh12312412K first-steps.md 4.0K intro.md125126// Order in short versions doesn't matter127$ ls -hs12812912K first-steps.md 4.0K intro.md130131// They all work the same 🎉132```133134</div>135136### *CLI option* short names with values137138When you use *CLI options* with short names, you can put them together if they are just boolean flags, like `--size` or `--human`.139140But if you have a *CLI option* `--file` with a short name `-f` that takes a value, if you put it with other short names for *CLI options*, you have to put it as the last letter, so that it can receive the value that comes right after.141142For example, let's say you are decompressing/extracting a file `myproject.tar.gz` with the program `tar`.143144You can pass these *CLI option* short names to `tar`:145146* `-x`: means "e`X`tract", to decompress and extract the contents.147* `-v`: means "`V`erbose", to print on the screen what it is doing, so you can know that it's decompressing each file and can entertain yourself while you wait.148* `-f`: means "`F`ile", this one requires a value, the compressed file to extract (in our example, this is `myproject.tar.gz`).149 * So if you use all the short names together, this `-f` has to come last, to receive the value that comes next to it.150151For example:152153<div class="termy">154155```console156$ tar -xvf myproject.tar.gz157158myproject/159myproject/first-steps.md160myproject/intro.md161162// But if you put the -f before163$ tar -fxv myproject.tar.gz164165// You get an ugly error166tar: You must specify one of the blah, blah, error, error167```168169</div>170171### Defining *CLI option* short names172173In **Typer** you can also define *CLI option* short names the same way you can customize the long names.174175`typer.Option()` receives as a first function argument the default value, e.g. `None`, and all the next *positional* values are to define the *CLI option* name(s).176177!!! tip178 Remember the *positional* function arguments are those that don't have a keyword.179180 All the other function arguments/parameters you pass to `typer.Option()` like `prompt=True` and `help="This option blah, blah"` require the keyword.181182You can overwrite the *CLI option* name to use as in the previous example, but you can also declare extra alternatives, including short names.183184For example, extending the previous example, let's add a *CLI option* short name `-n`:185186```Python hl_lines="4"187{!./src/options/name/tutorial002.py!}188```189190Here we are overwriting the *CLI option* name that by default would be `--user-name`, and we are defining it to be `--name`. And we are also declaring a *CLI option* short name of `-n`.191192Check it:193194<div class="termy">195196```console197// Check the help198$ python main.py --help199200// Notice the two CLI option names -n and --name201Usage: main.py [OPTIONS]202203Options:204 -n, --name TEXT [required]205 --install-completion Install completion for the current shell.206 --show-completion Show completion for the current shell, to copy it or customize the installation.207 --help Show this message and exit.208209// Try the short version210$ python main.py -n Camila211212Hello Camila213```214215</div>216217### *CLI option* only short name218219If you only declare a short name like `-n` then that will be the only *CLI option* name. And neither `--name` nor `--user-name` will be available.220221```Python hl_lines="4"222{!./src/options/name/tutorial003.py!}223```224225Check it:226227<div class="termy">228229```console230$ python main.py --help231232// Notice there's no --name nor --user-name, only -n233Usage: main.py [OPTIONS]234235Options:236 -n TEXT [required]237 --install-completion Install completion for the current shell.238 --show-completion Show completion for the current shell, to copy it or customize the installation.239 --help Show this message and exit.240241// Try it242$ python main.py -n Camila243244Hello Camila245```246247</div>248249### *CLI option* short name and default250251Continuing with the example above, as **Typer** allows you to declare a *CLI option* as having only a short name, if you want to have the default long name plus a short name, you have to declare both explicitly:252253```Python hl_lines="4"254{!./src/options/name/tutorial004.py!}255```256257Check it:258259<div class="termy">260261```console262$ python main.py --help263264// Notice that we have the long version --user-name back265// and we also have the short version -n266Usage: main.py [OPTIONS]267268Options:269 -n, --user-name TEXT [required]270 --install-completion Install completion for the current shell.271 --show-completion Show completion for the current shell, to copy it or customize the installation.272 --help Show this message and exit.273274// Try it275$ python main.py --user-name Camila276277Hello Camila278279// And try the short version280$ python main.py -n Camila281```282283</div>284285### *CLI option* short names together286287You can create multiple short names and use them together.288289You don't have to do anything special for it to work (apart from declaring those short versions):290291```Python hl_lines="5 6"292{!./src/options/name/tutorial005.py!}293```294295!!! tip296 Notice that, again, we are declaring the long and short version of the *CLI option* names.297298Check it:299300<div class="termy">301302```console303$ python main.py --help304305// We now have short versions -n and -f306// And also long versions --name and --formal307Usage: main.py [OPTIONS]308309Options:310 -n, --name TEXT [required]311 -f, --formal312 --install-completion Install completion for the current shell.313 --show-completion Show completion for the current shell, to copy it or customize the installation.314 --help Show this message and exit.315316// Try the short versions317$ python main.py -n Camila -f318319Good day Ms. Camila.320321// And try the 2 short versions together322// See how -n has to go last, to be able to get the value323$ python main.py -fn Camila324325Good day Ms. Camila.326```327328</div>
added:docs/tutorial/options/prompt.md+88 added
1It's also possible to, instead of just showing an error, ask for the missing value with `prompt=True`:23```Python hl_lines="4"4{!./src/options/prompt/tutorial001.py!}5```67And then your program will ask the user for it in the terminal:89<div class="termy">1011```console12// Call it with the NAME CLI argument13$ python main.py Camila1415// It asks for the missing CLI option --lastname16# Lastname: $ Gutiérrez1718Hello Camila Gutiérrez19```2021</div>2223## Customize the prompt2425You can also set a custom prompt, passing the string that you want to use instead of just `True`:2627```Python hl_lines="6"28{!./src/options/prompt/tutorial002.py!}29```3031And then your program will ask for it using with your custom prompt:3233<div class="termy">3435```console36// Call it with the NAME CLI argument37$ python main.py Camila3839// It uses the custom prompt40# Please tell me your last name: $ Gutiérrez4142Hello Camila Gutiérrez43```4445</div>4647## Confirmation prompt4849In some cases you could want to prompt for something and then ask the user to confirm it by typing it twice.5051You can do it passing the parameter `confirmation_prompt=True`.5253Let's say it's a CLI app to delete a project:5455```Python hl_lines="4"56{!./src/options/prompt/tutorial003.py!}57```5859And it will prompt the user for a value and then for the confirmation:6061<div class="termy">6263```console64$ python main.py6566// Your app will first prompt for the project name, and then for the confirmation67# Project name: $ Old Project68# Repeat for confirmation: $ Old Project6970Deleting project Old Project7172// If the user doesn't type the same, receives an error and a new prompt73$ python main.py7475# Project name: $ Old Project76# Repeat for confirmation: $ New Spice7778Error: the two entered values do not match7980# Project name: $ Old Project81# Repeat for confirmation: $ Old Project8283Deleting project Old Project8485// Now it works 🎉86```8788</div>
added:docs/tutorial/options/required.md+56 added
1We said before that *by default*:23* *CLI options* are **optional**4* *CLI arguments* are **required**56Well, that's how they work *by default*, and that's the convention in many CLI programs and systems.78But if you really want, you can change that.910To make a *CLI option* required, pass `...` to `typer.Option()`.1112!!! info13 If you hadn't seen that `...` before: it is a a special single value, it is <a href="https://docs.python.org/3/library/constants.html#Ellipsis" target="_blank">part of Python and is called "Ellipsis"</a>.1415That will tell **Typer** that it's still a *CLI option*, but it doesn't have a default value, and it's required.1617Let's make `--lastname` a required *CLI option*:1819```Python hl_lines="4"20{!./src/options/required/tutorial001.py!}21```2223And test it:2425<div class="termy">2627```console28// Pass the NAME CLI argument29$ python main.py Camila3031// We didn't pass the now required --lastname CLI option32Usage: main.py [OPTIONS] NAME33Try "main.py --help" for help.3435Error: Missing option "--lastname".3637// Now update it to pass the required --lastname CLI option38$ python main.py Camila --lastname Gutiérrez3940Hello Camila Gutiérrez4142// And if you check the help43$ python main.py --help4445Usage: main.py [OPTIONS] NAME4647Options:48 --lastname TEXT [required]49 --install-completion Install completion for the current shell.50 --show-completion Show completion for the current shell, to copy it or customize the installation.51 --help Show this message and exit.5253// It now tells you that --lastname is required 🎉54```5556</div>
modified:docs/tutorial/arguments.md+5 added-10 removed
1The same way that you have `typer.Option()` to help you define things for *CLI options*, there's also the equivalent `typer.Argument()` for *CLI arguments*.1Let's see how to configure *CLI arguments* with `typer.Argument()`.23## Optional *CLI arguments*45We said before that *by default*:
56 unmodified lines
62```Python63name: str = typer.Argument(...)64```6566The same as with `typer.Option()`, there is a `typer.Argument()`.66But now as `typer.Argument()` is the "default value" of the function's parameter, it would mean that "it is no longer required" (in Python terms).6768And now as `typer.Argument()` is the "default value" of the function's parameter, in Python terms, it would mean that "it is no longer required" (in Python terms).68As we no longer have the Python function default value (or its absence) to tell if something is required or not and what is the default value, the first parameter to `typer.Argument()` serves the same purpose of defining that default value, or making it required.6970As we no longer have the Python function default value (or its absence) to tell it if something is required or not and what is the default value, the first parameter to `typer.Argument()` serves the same purpose of defining that default value, or making it required.70To make it *required*, we pass `...` as the first function argument passed to `typer.Argument(...)`.7172To make it *required*, we pass `...` as that first parameter to the function.7372!!! info73 If you hadn't seen that `...` before: it is a a special single value, it is <a href="https://docs.python.org/3/library/constants.html#Ellipsis" target="_blank">part of Python and is called "Ellipsis"</a>.7477!!! tip78 This works exactly the same way `typer.Option()` does.7975All we did there achieves the same thing as before, a **required** *CLI argument*:7677<div class="termy">78
65 unmodified lines
144145Hello World!146147// With one optional CLI argument153$ python main.py148$ python main.py Camila149150Hello Camila151```152
56 unmodified lines
deleted:docs/tutorial/commands.md-555 removed
1We have seen how to create a CLI program with possibly several *CLI Options* and *CLI Arguments*.23But **Typer** allows you to create CLI programs with several commands (also known as subcommands).45For example, the program `git` has several commands.67One command of `git` is `git push`. And `git push` in turn takes its own *CLI arguments* and *CLI options*.89For example:1011<div class="termy">1213```console14// The push command with no parameters15$ git push1617---> 100%1819// The push command with one CLI option --set-upstream and 2 CLI arguments20$ git push --set-upstream origin master2122---> 100%23```2425</div>2627Another command of `git` is `git pull`, it also has some *CLI parameters*.2829It's like if the same big program `git` had several small programs inside.3031!!! tip32 A command looks the same as a *CLI argument*, it's just some name without a preceding `--`. But commands have predefined name, and are used to group different sets of functionalities into the same CLI application.3334## Command or subcommand3536It's common to call a CLI program a "command".3738But when one of these programs have subcommands, those subcommands are also frequently called just "commands".3940Have that in mind so you don't get confused.4142Here I'll use **CLI application** or **program** to refer to the program you are building in Python with Typer, and **command** to refer to one of these "subcommands" of your program.4344## Explicit application4546Before creating CLI applications with multiple commands/subcommands we need to understand how to create an explicit `typer.Typer()` application.4748In the *CLI Options* and *CLI Argument* tutorials you have seen how to create a single function and then pass that function to `typer.run()`.4950For example:5152```Python hl_lines="9"53{!./src/first_steps/tutorial002.py!}54```5556But that is actually a shortcut. Under the hood, **Typer** converts that to a CLI application with `typer.Typer()` and executes it. All that inside of `typer.run()`.5758There's also a more explicit way to achieve the same:5960```Python hl_lines="3 6 12"61{!./src/commands/tutorial001.py!}62```6364When you use `typer.run()`, **Typer** is doing more or less the same as above, it will:6566* Create a new `typer.Typer()` "application".67* Create a new "`command`" with your function.68* Call the same "application" as if it was a function with "`app()`".6970!!! info "`@decorator` Info"71 That `@something` syntax in Python is called a "decorator".7273 You put it on top of a function. Like a pretty decorative hat (I guess that's where the term came from).7475 A "decorator" takes the function below and does something with it.7677 In our case, this decorator tells **Typer** that the function below is a "`command`".7879Both ways, with `typer.run()` and creating the explicit application, achieve the same.8081!!! tip82 If your use case is solved with just `typer.run()`, that's fine, you don't have to create the explicit `app` and use `@app.command()`, etc.8384 You might want to do that later when your app needs the extra features, but if it doesn't need them yet, that's fine.8586If you run the second example, with the explicit `app`, it works exactly the same:8788<div class="termy">8990```console91// Without a CLI argument92$ python main.py9394Usage: main.py [OPTIONS] NAME95Try "main.py --help" for help.9697Error: Missing argument "NAME".9899// With the NAME CLI argument100$ python main.py Camila101102Hello Camila103104// Asking for help105$ python main.py --help106107Usage: main.py [OPTIONS] NAME108109Options:110 --install-completion Install completion for the current shell.111 --show-completion Show completion for the current shell, to copy it or customize the installation.112 --help Show this message and exit.113```114115</div>116117## A CLI application with multiple commands118119Coming back to the CLI applications with multiple commands/subcommands, **Typer** allows creating CLI applications with multiple of them.120121Now that you know how to create an explicit `typer.Typer()` application and add one command, let's see how to add multiple commands.122123Let's say that we have a CLI application to manage users.124125We'll have a command to `create` users and another command to `delete` them.126127To begin, let's say it can only create and delete one single predefined user:128129```Python hl_lines="6 11"130{!./src/commands/tutorial002.py!}131```132133Now we have a CLI application with 2 commands, `create` and `delete`:134135<div class="termy">136137```console138// Check the help139$ python main.py --help140141Usage: main.py [OPTIONS] COMMAND [ARGS]...142143Options:144 --install-completion Install completion for the current shell.145 --show-completion Show completion for the current shell, to copy it or customize the installation.146 --help Show this message and exit.147148Commands:149 create150 delete151152// Test them153$ python main.py create154155Creating user: Hiro Hamada156157$ python main.py delete158159Deleting user: Hiro Hamada160161// Now we have 2 commands! 🎉162```163164</div>165166Notice that the help text now shows the 2 commands: `create` and `delete`.167168!!! tip169 By default, the names of the commands are generated from the function name.170171## Command *CLI arguments*172173The same way as with a CLI application with a single command, subcommands (or just "commands") can also have their own *CLI arguments*:174175```Python hl_lines="7 12"176{!./src/commands/tutorial003.py!}177```178179<div class="termy">180181```console182// Check the help for create183$ python main.py create --help184185Usage: main.py create [OPTIONS] USERNAME186187Options:188 --help Show this message and exit.189190// Call it with a CLI argument191$ python main.py create Camila192193Creating user: Camila194195// The same for delete196$ python main.py delete Camila197198Deleting user: Camila199```200201</div>202203!!! tip204 Everything to the *right* of the *command* are *CLI parameters* (*CLI arguments* and *CLI options*) for that command.205206!!! note "Technical Details"207 Actually, it's everything to the right of that command, *before any subcommand*.208209 It's possible to have groups of *subcommands*, it's like if one *command* also had *subcommands*. And then those *subcommands* could have their own *CLI parameters*, taking their own *CLI parameters*.210211 You will see about them later in another section.212213## Command *CLI options*214215Commands can also have their own *CLI options*.216217In fact, each command can have different *CLI arguments* and *CLI options*:218219```Python hl_lines="7 13 14 24 33"220{!./src/commands/tutorial004.py!}221```222223Here we have multiple commands, with different *CLI parameters*:224225* `create`:226 * `username`: a *CLI argument*.227* `delete`:228 * `username`: a *CLI argument*.229 * `--force`: a *CLI option*, if not provided, it's prompted.230* `delete-all`:231 * `--force`: a *CLI option*, if not provided, it's prompted.232* `init`:233 * Doesn't take any *CLI parameters*.234235<div class="termy">236237```console238// Check the help239python main.py --help240241Usage: main.py [OPTIONS] COMMAND [ARGS]...242243Options:244 --install-completion Install completion for the current shell.245 --show-completion Show completion for the current shell, to copy it or customize the installation.246 --help Show this message and exit.247248Commands:249 create250 delete251 delete-all252 info253```254255</div>256257!!! tip258 Check the command `delete-all`, by default command names are generated from the function name, replacing `_` with `-`.259260Test it:261262<div class="termy">263264```console265// Check the command create266$ python main.py create Camila267268Creating user: Camila269270// Now test the command delete271$ python main.py delete Camila272273# Are you sure you want to delete the user? [y/N]: $ y274275Deleting user: Camila276277$ python main.py delete Wade278279# Are you sure you want to delete the user? [y/N]: $ n280281Operation cancelled282283// And finally, the command delete-all284// Notice it doesn't have CLI arguments, only a CLI option285286$ python main.py delete-all287288# Are you sure you want to delete ALL users? [y/N]: $ y289290Deleting all users291292$ python main.py delete-all293294# Are you sure you want to delete ALL users? [y/N]: $ n295296Operation cancelled297298// And if you pass the --force CLI option, it doesn't need to confirm299300$ python main.py delete-all --force301302Deleting all users303304// And init that doesn't take any CLI parameter305$ python main.py init306307Initializing user database308```309310</div>311312## Command help313314The same as before, you can add help for the commands in the docstrings and the *CLI options*.315316And the `typer.Typer()` application receives a parameter `help` that you can pass with the main help text for your CLI program:317318```Python hl_lines="3 8 9 10 20 23 24 25 26 27 39 42 43 44 45 46 55 56 57"319{!./src/commands/tutorial005.py!}320```321322Check it:323324<div class="termy">325326```console327// Check the new help328$ python main.py --help329330Usage: main.py [OPTIONS] COMMAND [ARGS]...331332 Awesome CLI user manager.333334Options:335 --install-completion Install completion for the current shell.336 --show-completion Show completion for the current shell, to copy it or customize the installation.337 --help Show this message and exit.338339Commands:340 create Create a new user with USERNAME.341 delete Delete a user with USERNAME.342 delete-all Delete ALL users in the database.343 init Initialize the users database.344345// Now the commands have inline help 🎉346347// Check the help for create348$ python main.py create --help349350Usage: main.py create [OPTIONS] USERNAME351352 Create a new user with USERNAME.353354Options:355 --help Show this message and exit.356357// Check the help for delete358$ python main.py delete --help359360Usage: main.py delete [OPTIONS] USERNAME361362 Delete a user with USERNAME.363364 If --force is not used, will ask for confirmation.365366Options:367 --force / --no-force Force deletion without confirmation. [required]368 --help Show this message and exit.369370// Check the help for delete-all371$ python main.py delete-all --help372373Usage: main.py delete-all [OPTIONS]374375 Delete ALL users in the database.376377 If --force is not used, will ask for confirmation.378379Options:380 --force / --no-force Force deletion without confirmation. [required]381 --help Show this message and exit.382383// Check the help for init384$ python main.py init --help385386Usage: main.py init [OPTIONS]387388 Initialize the users database.389390Options:391 --help Show this message and exit.392```393394</div>395396!!! tip397 `typer.Typer()` receives several other parameters for other things, we'll see that later.398399 You will also see how to use "Callbacks" later, and those include a way to add this same help message in a function docstring.400401## Custom command name402403By default, the command names are generated from the function name.404405So, if your function is something like:406407```Python408def create(username: str):409 ...410```411412Then the command name will be `create`.413414But if you already had a function called `create()` somewhere in your code, you would have to name your CLI function differently.415416And what if you wanted the command to still be named `create`?417418For this, you can set the name of the command in the first parameter for the `@app.command()` decorator:419420```Python hl_lines="6 11"421{!./src/commands/tutorial006.py!}422```423424Now, even though the functions are named `cli_create_user()` and `cli_delete_user()`, the commands will still be named `create` and `delete`:425426<div class="termy">427428```console429$ python main.py --help430431Usage: main.py [OPTIONS] COMMAND [ARGS]...432433Options:434 --install-completion Install completion for the current shell.435 --show-completion Show completion for the current shell, to copy it or customize the installation.436 --help Show this message and exit.437438Commands:439 create440 delete441442// Test it443$ python main.py create Camila444445Creating user: Camila446```447448</div>449450## One command vs multiple commands451452You might have noticed that if you create a single command, as in the first example:453454```Python hl_lines="3 6 12"455{!./src/commands/tutorial001.py!}456```457458**Typer** is smart enough to create a CLI application with that single function as the main CLI application, not as a command/subcommand:459460<div class="termy">461462```console463// Without a CLI argument464$ python main.py465466Usage: main.py [OPTIONS] NAME467Try "main.py --help" for help.468469Error: Missing argument "NAME".470471// With the NAME CLI argument472$ python main.py Camila473474Hello Camila475476// Asking for help477$ python main.py478479Usage: main.py [OPTIONS] NAME480481Options:482 --install-completion Install completion for the current shell.483 --show-completion Show completion for the current shell, to copy it or customize the installation.484 --help Show this message and exit.485```486487</div>488489!!! tip490 Notice that it doesn't show a command `main`, even though the function name is `main`.491492But if you add multiple commands, **Typer** will create one *CLI command* for each one of them:493494```Python hl_lines="6 11"495{!./src/commands/tutorial002.py!}496```497498Here we have 2 commands `create` and `delete`:499500<div class="termy">501502```console503// Check the help504$ python main.py --help505506Usage: main.py [OPTIONS] COMMAND [ARGS]...507508Options:509 --install-completion Install completion for the current shell.510 --show-completion Show completion for the current shell, to copy it or customize the installation.511 --help Show this message and exit.512513Commands:514 create515 delete516517// Test the commands518$ python main.py create519520Creating user: Hiro Hamada521522$ python main.py delete523524Deleting user: Hiro Hamada525```526527</div>528529!!! tip530 This is **Typer**'s behavior by default, but you could still create a CLI application with one single command, like:531532 ```533 $ python main.py main534 ```535536 instead of just:537538 ```539 $ python main.py540 ```541542 You will learn more about this in the section about application Callbacks.543544## Decorator Technical Details545546When you use `@app.command()` the function under the decorator is registered in the **Typer** application and is then used later by the application.547548But Typer doesn't modify that function itself, the function is left as is.549550That means that if your function is simple enough that you could create it without using `typer.Option()` or `typer.Argument()`, you could use the same function for a **Typer** application and a **FastAPI** application putting both decorators on top, or similar tricks.551552!!! note "Click Technical Details"553 This behavior is a design difference with Click.554555 In Click, when you add a `@click.command()` decorator it actually modifies the function underneath and replaces it with an object.
deleted:docs/tutorial/options.md-263 removed
1## *CLI options* with help23In the *First Steps* section you saw how to add help for a CLI app/command by adding it to a function's <abbr title="a multi-line string as the first expression inside a function (not assigned to any variable) used for documentation">docstring</abbr>.45Here's how that last example looked like:67```Python8{!./src/first_steps/tutorial006.py!}9```1011Now we'll add a *help* section to the *CLI options*:1213```Python hl_lines="6 7"14{!./src/options/tutorial001.py!}15```1617We are replacing the default values we had before with `typer.Option()`.1819As we no longer have a default value there, the first parameter to `typer.Option()` serves the same purpose of defining that default value.2021So, if we had:2223```Python24lastname: str = ""25```2627now we write:2829```Python30lastname: str = typer.Option("")31```3233And both forms achieve the same: a *CLI option* with a default value of an empty string (`""`).3435And then we can pass the `help` keyword parameter:3637```Python38lastname: str = typer.Option("", help="this option does this and that")39```4041to create the help for that *CLI option*.4243Copy that example from above to a file `main.py`.4445Test it:4647<div class="termy">4849```console50$ python main.py --help5152Usage: main.py [OPTIONS] NAME5354 Say hi to NAME, optionally with a --lastname.5556 If --formal is used, say hi very formally.5758Options:59 --lastname TEXT Last name of person to greet.60 --formal / --no-formal Say hi formally.61 --install-completion Install completion for the current shell.62 --show-completion Show completion for the current shell, to copy it or customize the installation.63 --help Show this message and exit.6465// Now you have a help text for the --lastname and --formal CLI options 🎉66```6768</div>6970## Make a *CLI option* required7172We said before that *by default*:7374* *CLI options* are **optional**75* *CLI arguments* are **required**7677Well, that's how they work *by default*, and that's the convention in many CLI programs and systems.7879But if you really want, you can change that.8081To make a *CLI option* required, pass `...` to `typer.Option()`.8283!!! info84 If you hadn't seen that `...` before: it is a a special single value, it is <a href="https://docs.python.org/3/library/constants.html#Ellipsis" target="_blank">part of Python and is called "Ellipsis"</a>.8586That will tell **Typer** that it's still a *CLI option*, but it doesn't have a default value, and it's required.8788Let's make the `--lastname` a required *CLI option*.8990We'll also simplify the example to focus on the new parts:9192```Python hl_lines="4"93{!./src/options/tutorial002.py!}94```9596!!! tip97 You could still add `help` to `typer.Option()` as before, but we are omitting it here to simplify the example.9899And test it:100101<div class="termy">102103```console104// Pass the NAME CLI argument105$ python main.py Camila106107// We didn't pass the now required --lastname CLI option108Usage: main.py [OPTIONS] NAME109Try "main.py --help" for help.110111Error: Missing option "--lastname".112113// Now update it to pass the required --lastname CLI option114$ python main.py Camila --lastname Gutiérrez115116Hello Camila Gutiérrez117118// And if you check the help119$ python main.py --help120121Usage: main.py [OPTIONS] NAME122123Options:124 --lastname TEXT [required]125 --install-completion Install completion for the current shell.126 --show-completion Show completion for the current shell, to copy it or customize the installation.127 --help Show this message and exit.128129// It now tells you that --lastname is required 🎉130```131132</div>133134## Prompt for a *CLI option*135136It's also possible to, instead of just showing an error, ask for the missing value with `prompt=True`:137138```Python hl_lines="4"139{!./src/options/tutorial003.py!}140```141142And then your program will ask the user for it in the terminal:143144<div class="termy">145146```console147// Call it with the NAME CLI argument148$ python main.py Camila149150// It asks for the missing CLI option --lastname151# Lastname: $ Gutiérrez152153Hello Camila Gutiérrez154```155156</div>157158### Customize the prompt159160You can also set a custom prompt, passing the string that you want to use instead of just `True`:161162```Python hl_lines="6"163{!./src/options/tutorial004.py!}164```165166And then your program will ask for it using with your custom prompt:167168<div class="termy">169170```console171// Call it with the NAME CLI argument172$ python main.py Camila173174// It uses the custom prompt175# Please tell me your last name: $ Gutiérrez176177Hello Camila Gutiérrez178```179180</div>181182## Confirmation prompt183184In some cases you could want to prompt for something and then ask the user to confirm it by typing it twice.185186You can do it passing the parameter `confirmation_prompt=True`.187188Let's say it's a CLI app to delete a project:189190```Python hl_lines="4"191{!./src/options/tutorial005.py!}192```193194And it will prompt the user for a value and then for the confirmation:195196<div class="termy">197198```console199$ python main.py200201// Your app will first prompt for the project name, and then for the confirmation202# Project name: $ Old Project203# Repeat for confirmation: $ Old Project204205Deleting project Old Project206207// If the user doesn't type the same, receives an error and a new prompt208$ python main.py209210# Project name: $ Old Project211# Repeat for confirmation: $ New Spice212213Error: the two entered values do not match214215# Project name: $ Old Project216# Repeat for confirmation: $ Old Project217218Deleting project Old Project219220// Now it works 🎉221```222223</div>224225## Show default in help226227You can tell Typer to show the default value in the help text with `show_default=True`:228229```Python hl_lines="4"230{!./src/options/tutorial006.py!}231```232233And it will show up in the help text:234235<div class="termy">236237```console238$ python main.py239240Hello Wade Wilson241242// Show the help243$ python main.py --help244245Usage: main.py [OPTIONS]246247Options:248 --fullname TEXT [default: Wade Wilson]249 --install-completion Install completion for the current shell.250 --show-completion Show completion for the current shell, to copy it or customize the installation.251 --help Show this message and exit.252```253254</div>255256!!! tip257 Notice the `[default: Wade Wilson]` in the help text.258259## Other uses260261`typer.Option()` has several other users. For data validation, to enable other features, etc.262263But you will see about that later in the docs.
added:tests/test_tutorial/test_commands/test_arguments/__init__.py
added:tests/test_tutorial/test_commands/test_arguments/test_tutorial001.py+42 added
1import subprocess2from commands.arguments import tutorial001 as mod34from typer.testing import CliRunner56app = mod.app78runner = CliRunner()91011def test_help_create():12 result = runner.invoke(app, ["create", "--help"])13 assert result.exit_code == 014 assert "create [OPTIONS] USERNAME" in result.output151617def test_help_delete():18 result = runner.invoke(app, ["delete", "--help"])19 assert result.exit_code == 020 assert "delete [OPTIONS] USERNAME" in result.output212223def test_create():24 result = runner.invoke(app, ["create", "Camila"])25 assert result.exit_code == 026 assert "Creating user: Camila" in result.output272829def test_delete():30 result = runner.invoke(app, ["delete", "Camila"])31 assert result.exit_code == 032 assert "Deleting user: Camila" in result.output333435def test_script():36 result = subprocess.run(37 ["coverage", "run", mod.__file__, "--help"],38 stdout=subprocess.PIPE,39 stderr=subprocess.PIPE,40 encoding="utf-8",41 )42 assert "Usage" in result.stdout
added:tests/test_tutorial/test_commands/test_help/__init__.py
added:tests/test_tutorial/test_commands/test_help/test_tutorial001.py+106 added
1import subprocess2from commands.help import tutorial001 as mod34from typer.testing import CliRunner56app = mod.app78runner = CliRunner()91011def test_help():12 result = runner.invoke(app, ["--help"])13 assert result.exit_code == 014 assert "Awesome CLI user manager." in result.output15 assert "create" in result.output16 assert "Create a new user with USERNAME." in result.output17 assert "delete" in result.output18 assert "Delete a user with USERNAME." in result.output19 assert "delete-all" in result.output20 assert "Delete ALL users in the database." in result.output21 assert "init" in result.output22 assert "Initialize the users database." in result.output232425def test_help_create():26 result = runner.invoke(app, ["create", "--help"])27 assert result.exit_code == 028 assert "create [OPTIONS] USERNAME" in result.output29 assert "Create a new user with USERNAME." in result.output303132def test_help_delete():33 result = runner.invoke(app, ["delete", "--help"])34 assert result.exit_code == 035 assert "delete [OPTIONS] USERNAME" in result.output36 assert "Delete a user with USERNAME." in result.output37 assert "--force / --no-force" in result.output38 assert "Force deletion without confirmation." in result.output394041def test_help_delete_all():42 result = runner.invoke(app, ["delete-all", "--help"])43 assert result.exit_code == 044 assert "delete-all [OPTIONS]" in result.output45 assert "Delete ALL users in the database." in result.output46 assert "If --force is not used, will ask for confirmation." in result.output47 assert "[required]" in result.output48 assert "--force / --no-force" in result.output49 assert "Force deletion without confirmation." in result.output505152def test_help_init():53 result = runner.invoke(app, ["init", "--help"])54 assert result.exit_code == 055 assert "init [OPTIONS]" in result.output56 assert "Initialize the users database." in result.output575859def test_create():60 result = runner.invoke(app, ["create", "Camila"])61 assert result.exit_code == 062 assert "Creating user: Camila" in result.output636465def test_delete():66 result = runner.invoke(app, ["delete", "Camila"], input="y\n")67 assert result.exit_code == 068 assert "Are you sure you want to delete the user? [y/N]:" in result.output69 assert "Deleting user: Camila" in result.output707172def test_no_delete():73 result = runner.invoke(app, ["delete", "Camila"], input="n\n")74 assert result.exit_code == 075 assert "Are you sure you want to delete the user? [y/N]:" in result.output76 assert "Operation cancelled" in result.output777879def test_delete_all():80 result = runner.invoke(app, ["delete-all",], input="y\n")81 assert result.exit_code == 082 assert "Are you sure you want to delete ALL users? [y/N]:" in result.output83 assert "Deleting all users" in result.output848586def test_no_delete_all():87 result = runner.invoke(app, ["delete-all",], input="n\n")88 assert result.exit_code == 089 assert "Are you sure you want to delete ALL users? [y/N]:" in result.output90 assert "Operation cancelled" in result.output919293def test_init():94 result = runner.invoke(app, ["init",])95 assert result.exit_code == 096 assert "Initializing user database" in result.output979899def test_script():100 result = subprocess.run(101 ["coverage", "run", mod.__file__, "--help"],102 stdout=subprocess.PIPE,103 stderr=subprocess.PIPE,104 encoding="utf-8",105 )106 assert "Usage" in result.stdout
added:tests/test_tutorial/test_commands/test_help/test_tutorial002.py+55 added
1import subprocess2from commands.help import tutorial002 as mod34from typer.testing import CliRunner56app = mod.app78runner = CliRunner()91011def test_help():12 result = runner.invoke(app, ["--help"])13 assert result.exit_code == 014 assert "create" in result.output15 assert "Create a new user with USERNAME." in result.output16 assert "delete" in result.output17 assert "Delete a user with USERNAME." in result.output18 assert "Some internal utility function to create." not in result.output19 assert "Some internal utility function to delete." not in result.output202122def test_help_create():23 result = runner.invoke(app, ["create", "--help"])24 assert result.exit_code == 025 assert "Create a new user with USERNAME." in result.output26 assert "Some internal utility function to create." not in result.output272829def test_help_create():30 result = runner.invoke(app, ["delete", "--help"])31 assert result.exit_code == 032 assert "Delete a user with USERNAME." in result.output33 assert "Some internal utility function to delete." not in result.output343536def test_create():37 result = runner.invoke(app, ["create", "Camila"])38 assert result.exit_code == 039 assert "Creating user: Camila" in result.output404142def test_delete():43 result = runner.invoke(app, ["delete", "Camila"])44 assert result.exit_code == 045 assert "Deleting user: Camila" in result.output464748def test_script():49 result = subprocess.run(50 ["coverage", "run", mod.__file__, "--help"],51 stdout=subprocess.PIPE,52 stderr=subprocess.PIPE,53 encoding="utf-8",54 )55 assert "Usage" in result.stdout
added:tests/test_tutorial/test_commands/test_index/__init__.py
added:tests/test_tutorial/test_commands/test_index/test_tutorial001.py+30 added
1import subprocess2from commands.index import tutorial001 as mod34from typer.testing import CliRunner56app = mod.app78runner = CliRunner()91011def test_no_arg():12 result = runner.invoke(app)13 assert result.exit_code != 014 assert 'Error: Missing argument "NAME".' in result.output151617def test_arg():18 result = runner.invoke(app, ["Camila"])19 assert result.exit_code == 020 assert "Hello Camila" in result.output212223def test_script():24 result = subprocess.run(25 ["coverage", "run", mod.__file__, "--help"],26 stdout=subprocess.PIPE,27 stderr=subprocess.PIPE,28 encoding="utf-8",29 )30 assert "Usage" in result.stdout
added:tests/test_tutorial/test_commands/test_index/test_tutorial002.py+39 added
1import subprocess2from commands.index import tutorial002 as mod34from typer.testing import CliRunner56app = mod.app78runner = CliRunner()91011def test_help():12 result = runner.invoke(app, ["--help"])13 assert result.exit_code == 014 assert "[OPTIONS] COMMAND [ARGS]..." in result.output15 assert "Commands:" in result.output16 assert "create" in result.output17 assert "delete" in result.output181920def test_create():21 result = runner.invoke(app, ["create"])22 assert result.exit_code == 023 assert "Creating user: Hiro Hamada" in result.output242526def test_delete():27 result = runner.invoke(app, ["delete"])28 assert result.exit_code == 029 assert "Deleting user: Hiro Hamada" in result.output303132def test_script():33 result = subprocess.run(34 ["coverage", "run", mod.__file__, "--help"],35 stdout=subprocess.PIPE,36 stderr=subprocess.PIPE,37 encoding="utf-8",38 )39 assert "Usage" in result.stdout
added:tests/test_tutorial/test_commands/test_name/__init__.py
added:tests/test_tutorial/test_commands/test_name/test_tutorial001.py+38 added
1import subprocess2from commands.name import tutorial001 as mod34from typer.testing import CliRunner56app = mod.app78runner = CliRunner()91011def test_help():12 result = runner.invoke(app, ["--help"])13 assert result.exit_code == 014 assert "Commands:" in result.output15 assert "create" in result.output16 assert "delete" in result.output171819def test_create():20 result = runner.invoke(app, ["create", "Camila"])21 assert result.exit_code == 022 assert "Creating user: Camila" in result.output232425def test_delete():26 result = runner.invoke(app, ["delete", "Camila"])27 assert result.exit_code == 028 assert "Deleting user: Camila" in result.output293031def test_script():32 result = subprocess.run(33 ["coverage", "run", mod.__file__, "--help"],34 stdout=subprocess.PIPE,35 stderr=subprocess.PIPE,36 encoding="utf-8",37 )38 assert "Usage" in result.stdout
added:tests/test_tutorial/test_commands/test_options/__init__.py
added:tests/test_tutorial/test_commands/test_options/test_tutorial001.py+75 added
1import subprocess2from commands.options import tutorial001 as mod34from typer.testing import CliRunner56app = mod.app78runner = CliRunner()91011def test_help():12 result = runner.invoke(app, ["--help"])13 assert result.exit_code == 014 assert "Commands:" in result.output15 assert "create" in result.output16 assert "delete" in result.output17 assert "delete-all" in result.output18 assert "init" in result.output192021def test_create():22 result = runner.invoke(app, ["create", "Camila"])23 assert result.exit_code == 024 assert "Creating user: Camila" in result.output252627def test_delete():28 result = runner.invoke(app, ["delete", "Camila"], input="y\n")29 assert result.exit_code == 030 assert "Are you sure you want to delete the user? [y/N]:" in result.output31 assert "Deleting user: Camila" in result.output323334def test_no_delete():35 result = runner.invoke(app, ["delete", "Camila"], input="n\n")36 assert result.exit_code == 037 assert "Are you sure you want to delete the user? [y/N]:" in result.output38 assert "Operation cancelled" in result.output394041def test_delete_all():42 result = runner.invoke(app, ["delete-all"], input="y\n")43 assert result.exit_code == 044 assert "Are you sure you want to delete ALL users? [y/N]:" in result.output45 assert "Deleting all users" in result.output464748def test_no_delete_all():49 result = runner.invoke(app, ["delete-all"], input="n\n")50 assert result.exit_code == 051 assert "Are you sure you want to delete ALL users? [y/N]:" in result.output52 assert "Operation cancelled" in result.output535455def test_delete_all_force():56 result = runner.invoke(app, ["delete-all", "--force"])57 assert result.exit_code == 058 assert "Are you sure you want to delete ALL users? [y/N]:" not in result.output59 assert "Deleting all users" in result.output606162def test_init():63 result = runner.invoke(app, ["init"])64 assert result.exit_code == 065 assert "Initializing user database" in result.output666768def test_script():69 result = subprocess.run(70 ["coverage", "run", mod.__file__, "--help"],71 stdout=subprocess.PIPE,72 stderr=subprocess.PIPE,73 encoding="utf-8",74 )75 assert "Usage" in result.stdout
deleted:tests/test_tutorial/test_commands/test_tutorial001.py-30 removed
1import subprocess2from commands import tutorial001 as mod34from typer.testing import CliRunner56app = mod.app78runner = CliRunner()91011def test_no_arg():12 result = runner.invoke(app)13 assert result.exit_code != 014 assert 'Error: Missing argument "NAME".' in result.output151617def test_arg():18 result = runner.invoke(app, ["Camila"])19 assert result.exit_code == 020 assert "Hello Camila" in result.output212223def test_script():24 result = subprocess.run(25 ["coverage", "run", mod.__file__, "--help"],26 stdout=subprocess.PIPE,27 stderr=subprocess.PIPE,28 encoding="utf-8",29 )30 assert "Usage" in result.stdout
deleted:tests/test_tutorial/test_commands/test_tutorial002.py-39 removed
1import subprocess2from commands import tutorial002 as mod34from typer.testing import CliRunner56app = mod.app78runner = CliRunner()91011def test_help():12 result = runner.invoke(app, ["--help"])13 assert result.exit_code == 014 assert "[OPTIONS] COMMAND [ARGS]..." in result.output15 assert "Commands:" in result.output16 assert "create" in result.output17 assert "delete" in result.output181920def test_create():21 result = runner.invoke(app, ["create"])22 assert result.exit_code == 023 assert "Creating user: Hiro Hamada" in result.output242526def test_delete():27 result = runner.invoke(app, ["delete"])28 assert result.exit_code == 029 assert "Deleting user: Hiro Hamada" in result.output303132def test_script():33 result = subprocess.run(34 ["coverage", "run", mod.__file__, "--help"],35 stdout=subprocess.PIPE,36 stderr=subprocess.PIPE,37 encoding="utf-8",38 )39 assert "Usage" in result.stdout
deleted:tests/test_tutorial/test_commands/test_tutorial003.py-42 removed
1import subprocess2from commands import tutorial003 as mod34from typer.testing import CliRunner56app = mod.app78runner = CliRunner()91011def test_help_create():12 result = runner.invoke(app, ["create", "--help"])13 assert result.exit_code == 014 assert "create [OPTIONS] USERNAME" in result.output151617def test_help_delete():18 result = runner.invoke(app, ["delete", "--help"])19 assert result.exit_code == 020 assert "delete [OPTIONS] USERNAME" in result.output212223def test_create():24 result = runner.invoke(app, ["create", "Camila"])25 assert result.exit_code == 026 assert "Creating user: Camila" in result.output272829def test_delete():30 result = runner.invoke(app, ["delete", "Camila"])31 assert result.exit_code == 032 assert "Deleting user: Camila" in result.output333435def test_script():36 result = subprocess.run(37 ["coverage", "run", mod.__file__, "--help"],38 stdout=subprocess.PIPE,39 stderr=subprocess.PIPE,40 encoding="utf-8",41 )42 assert "Usage" in result.stdout
deleted:tests/test_tutorial/test_commands/test_tutorial004.py-75 removed
1import subprocess2from commands import tutorial004 as mod34from typer.testing import CliRunner56app = mod.app78runner = CliRunner()91011def test_help():12 result = runner.invoke(app, ["--help"])13 assert result.exit_code == 014 assert "Commands:" in result.output15 assert "create" in result.output16 assert "delete" in result.output17 assert "delete-all" in result.output18 assert "init" in result.output192021def test_create():22 result = runner.invoke(app, ["create", "Camila"])23 assert result.exit_code == 024 assert "Creating user: Camila" in result.output252627def test_delete():28 result = runner.invoke(app, ["delete", "Camila"], input="y\n")29 assert result.exit_code == 030 assert "Are you sure you want to delete the user? [y/N]:" in result.output31 assert "Deleting user: Camila" in result.output323334def test_no_delete():35 result = runner.invoke(app, ["delete", "Camila"], input="n\n")36 assert result.exit_code == 037 assert "Are you sure you want to delete the user? [y/N]:" in result.output38 assert "Operation cancelled" in result.output394041def test_delete_all():42 result = runner.invoke(app, ["delete-all"], input="y\n")43 assert result.exit_code == 044 assert "Are you sure you want to delete ALL users? [y/N]:" in result.output45 assert "Deleting all users" in result.output464748def test_no_delete_all():49 result = runner.invoke(app, ["delete-all"], input="n\n")50 assert result.exit_code == 051 assert "Are you sure you want to delete ALL users? [y/N]:" in result.output52 assert "Operation cancelled" in result.output535455def test_delete_all_force():56 result = runner.invoke(app, ["delete-all", "--force"])57 assert result.exit_code == 058 assert "Are you sure you want to delete ALL users? [y/N]:" not in result.output59 assert "Deleting all users" in result.output606162def test_init():63 result = runner.invoke(app, ["init"])64 assert result.exit_code == 065 assert "Initializing user database" in result.output666768def test_script():69 result = subprocess.run(70 ["coverage", "run", mod.__file__, "--help"],71 stdout=subprocess.PIPE,72 stderr=subprocess.PIPE,73 encoding="utf-8",74 )75 assert "Usage" in result.stdout
deleted:tests/test_tutorial/test_commands/test_tutorial005.py-106 removed
1import subprocess2from commands import tutorial005 as mod34from typer.testing import CliRunner56app = mod.app78runner = CliRunner()91011def test_help():12 result = runner.invoke(app, ["--help"])13 assert result.exit_code == 014 assert "Awesome CLI user manager." in result.output15 assert "create" in result.output16 assert "Create a new user with USERNAME." in result.output17 assert "delete" in result.output18 assert "Delete a user with USERNAME." in result.output19 assert "delete-all" in result.output20 assert "Delete ALL users in the database." in result.output21 assert "init" in result.output22 assert "Initialize the users database." in result.output232425def test_help_create():26 result = runner.invoke(app, ["create", "--help"])27 assert result.exit_code == 028 assert "create [OPTIONS] USERNAME" in result.output29 assert "Create a new user with USERNAME." in result.output303132def test_help_delete():33 result = runner.invoke(app, ["delete", "--help"])34 assert result.exit_code == 035 assert "delete [OPTIONS] USERNAME" in result.output36 assert "Delete a user with USERNAME." in result.output37 assert "--force / --no-force" in result.output38 assert "Force deletion without confirmation." in result.output394041def test_help_delete_all():42 result = runner.invoke(app, ["delete-all", "--help"])43 assert result.exit_code == 044 assert "delete-all [OPTIONS]" in result.output45 assert "Delete ALL users in the database." in result.output46 assert "If --force is not used, will ask for confirmation." in result.output47 assert "[required]" in result.output48 assert "--force / --no-force" in result.output49 assert "Force deletion without confirmation." in result.output505152def test_help_init():53 result = runner.invoke(app, ["init", "--help"])54 assert result.exit_code == 055 assert "init [OPTIONS]" in result.output56 assert "Initialize the users database." in result.output575859def test_create():60 result = runner.invoke(app, ["create", "Camila"])61 assert result.exit_code == 062 assert "Creating user: Camila" in result.output636465def test_delete():66 result = runner.invoke(app, ["delete", "Camila"], input="y\n")67 assert result.exit_code == 068 assert "Are you sure you want to delete the user? [y/N]:" in result.output69 assert "Deleting user: Camila" in result.output707172def test_no_delete():73 result = runner.invoke(app, ["delete", "Camila"], input="n\n")74 assert result.exit_code == 075 assert "Are you sure you want to delete the user? [y/N]:" in result.output76 assert "Operation cancelled" in result.output777879def test_delete_all():80 result = runner.invoke(app, ["delete-all",], input="y\n")81 assert result.exit_code == 082 assert "Are you sure you want to delete ALL users? [y/N]:" in result.output83 assert "Deleting all users" in result.output848586def test_no_delete_all():87 result = runner.invoke(app, ["delete-all",], input="n\n")88 assert result.exit_code == 089 assert "Are you sure you want to delete ALL users? [y/N]:" in result.output90 assert "Operation cancelled" in result.output919293def test_init():94 result = runner.invoke(app, ["init",])95 assert result.exit_code == 096 assert "Initializing user database" in result.output979899def test_script():100 result = subprocess.run(101 ["coverage", "run", mod.__file__, "--help"],102 stdout=subprocess.PIPE,103 stderr=subprocess.PIPE,104 encoding="utf-8",105 )106 assert "Usage" in result.stdout
deleted:tests/test_tutorial/test_commands/test_tutorial006.py-38 removed
1import subprocess2from commands import tutorial006 as mod34from typer.testing import CliRunner56app = mod.app78runner = CliRunner()91011def test_help():12 result = runner.invoke(app, ["--help"])13 assert result.exit_code == 014 assert "Commands:" in result.output15 assert "create" in result.output16 assert "delete" in result.output171819def test_create():20 result = runner.invoke(app, ["create", "Camila"])21 assert result.exit_code == 022 assert "Creating user: Camila" in result.output232425def test_delete():26 result = runner.invoke(app, ["delete", "Camila"])27 assert result.exit_code == 028 assert "Deleting user: Camila" in result.output293031def test_script():32 result = subprocess.run(33 ["coverage", "run", mod.__file__, "--help"],34 stdout=subprocess.PIPE,35 stderr=subprocess.PIPE,36 encoding="utf-8",37 )38 assert "Usage" in result.stdout
added:tests/test_tutorial/test_options/test_help/__init__.py
added:tests/test_tutorial/test_options/test_help/test_tutorial001.py+48 added
1import subprocess23import typer4from typer.testing import CliRunner56from options.help import tutorial001 as mod78runner = CliRunner()910app = typer.Typer()11app.command()(mod.main)121314def test_help():15 result = runner.invoke(app, ["--help"])16 assert result.exit_code == 017 assert "Say hi to NAME, optionally with a --lastname." in result.output18 assert "If --formal is used, say hi very formally." in result.output19 assert "Last name of person to greet." in result.output20 assert "Say hi formally." in result.output212223def test_1():24 result = runner.invoke(app, ["Camila"])25 assert result.exit_code == 026 assert "Hello Camila" in result.output272829def test_option_lastname():30 result = runner.invoke(app, ["Camila", "--lastname", "Gutiérrez"])31 assert result.exit_code == 032 assert "Hello Camila Gutiérrez" in result.output333435def test_formal():36 result = runner.invoke(app, ["Camila", "--lastname", "Gutiérrez", "--formal"])37 assert result.exit_code == 038 assert "Good day Ms. Camila Gutiérrez." in result.output394041def test_script():42 result = subprocess.run(43 ["coverage", "run", mod.__file__, "--help"],44 stdout=subprocess.PIPE,45 stderr=subprocess.PIPE,46 encoding="utf-8",47 )48 assert "Usage" in result.stdout
added:tests/test_tutorial/test_options/test_help/test_tutorial002.py+34 added
1import subprocess23import typer4from typer.testing import CliRunner56from options.help import tutorial002 as mod78runner = CliRunner()910app = typer.Typer()11app.command()(mod.main)121314def test_call():15 result = runner.invoke(app)16 assert result.exit_code == 017 assert "Hello Wade Wilson" in result.output181920def test_help():21 result = runner.invoke(app, ["--help"])22 assert result.exit_code == 023 assert "--fullname TEXT" in result.output24 assert "[default: Wade Wilson]" in result.output252627def test_script():28 result = subprocess.run(29 ["coverage", "run", mod.__file__, "--help"],30 stdout=subprocess.PIPE,31 stderr=subprocess.PIPE,32 encoding="utf-8",33 )34 assert "Usage" in result.stdout
added:tests/test_tutorial/test_options/test_name/__init__.py
added:tests/test_tutorial/test_options/test_name/test_tutorial001.py+34 added
1import subprocess23import typer4from typer.testing import CliRunner56from options.name import tutorial001 as mod78runner = CliRunner()910app = typer.Typer()11app.command()(mod.main)121314def test_option_help():15 result = runner.invoke(app, ["--help"])16 assert result.exit_code == 017 assert "--name TEXT" in result.output18 assert "--user-name" not in result.output192021def test_call():22 result = runner.invoke(app, ["--name", "Camila"])23 assert result.exit_code == 024 assert "Hello Camila" in result.output252627def test_script():28 result = subprocess.run(29 ["coverage", "run", mod.__file__, "--help"],30 stdout=subprocess.PIPE,31 stderr=subprocess.PIPE,32 encoding="utf-8",33 )34 assert "Usage" in result.stdout
added:tests/test_tutorial/test_options/test_name/test_tutorial002.py+40 added
1import subprocess23import typer4from typer.testing import CliRunner56from options.name import tutorial002 as mod78runner = CliRunner()910app = typer.Typer()11app.command()(mod.main)121314def test_option_help():15 result = runner.invoke(app, ["--help"])16 assert result.exit_code == 017 assert "-n, --name TEXT" in result.output18 assert "--user-name" not in result.output192021def test_call():22 result = runner.invoke(app, ["-n", "Camila"])23 assert result.exit_code == 024 assert "Hello Camila" in result.output252627def test_call_long():28 result = runner.invoke(app, ["--name", "Camila"])29 assert result.exit_code == 030 assert "Hello Camila" in result.output313233def test_script():34 result = subprocess.run(35 ["coverage", "run", mod.__file__, "--help"],36 stdout=subprocess.PIPE,37 stderr=subprocess.PIPE,38 encoding="utf-8",39 )40 assert "Usage" in result.stdout
added:tests/test_tutorial/test_options/test_name/test_tutorial003.py+35 added
1import subprocess23import typer4from typer.testing import CliRunner56from options.name import tutorial003 as mod78runner = CliRunner()910app = typer.Typer()11app.command()(mod.main)121314def test_option_help():15 result = runner.invoke(app, ["--help"])16 assert result.exit_code == 017 assert "-n TEXT" in result.output18 assert "--user-name" not in result.output19 assert "--name" not in result.output202122def test_call():23 result = runner.invoke(app, ["-n", "Camila"])24 assert result.exit_code == 025 assert "Hello Camila" in result.output262728def test_script():29 result = subprocess.run(30 ["coverage", "run", mod.__file__, "--help"],31 stdout=subprocess.PIPE,32 stderr=subprocess.PIPE,33 encoding="utf-8",34 )35 assert "Usage" in result.stdout
added:tests/test_tutorial/test_options/test_name/test_tutorial004.py+40 added
1import subprocess23import typer4from typer.testing import CliRunner56from options.name import tutorial004 as mod78runner = CliRunner()910app = typer.Typer()11app.command()(mod.main)121314def test_option_help():15 result = runner.invoke(app, ["--help"])16 assert result.exit_code == 017 assert "-n, --user-name TEXT" in result.output18 assert "--name" not in result.output192021def test_call():22 result = runner.invoke(app, ["-n", "Camila"])23 assert result.exit_code == 024 assert "Hello Camila" in result.output252627def test_call_long():28 result = runner.invoke(app, ["--user-name", "Camila"])29 assert result.exit_code == 030 assert "Hello Camila" in result.output313233def test_script():34 result = subprocess.run(35 ["coverage", "run", mod.__file__, "--help"],36 stdout=subprocess.PIPE,37 stderr=subprocess.PIPE,38 encoding="utf-8",39 )40 assert "Usage" in result.stdout
added:tests/test_tutorial/test_options/test_name/test_tutorial005.py+51 added
1import subprocess23import typer4from typer.testing import CliRunner56from options.name import tutorial005 as mod78runner = CliRunner()910app = typer.Typer()11app.command()(mod.main)121314def test_option_help():15 result = runner.invoke(app, ["--help"])16 assert result.exit_code == 017 assert "-n, --name TEXT" in result.output18 assert "-f, --formal" in result.output192021def test_call():22 result = runner.invoke(app, ["-n", "Camila"])23 assert result.exit_code == 024 assert "Hello Camila" in result.output252627def test_call_formal():28 result = runner.invoke(app, ["-n", "Camila", "-f"])29 assert result.exit_code == 030 assert "Good day Ms. Camila." in result.output313233def test_call_formal_condensed():34 result = runner.invoke(app, ["-fn", "Camila"])35 assert result.exit_code == 036 assert "Good day Ms. Camila." in result.output373839def test_call_condensed_wrong_order():40 result = runner.invoke(app, ["-nf", "Camila"])41 assert result.exit_code != 0424344def test_script():45 result = subprocess.run(46 ["coverage", "run", mod.__file__, "--help"],47 stdout=subprocess.PIPE,48 stderr=subprocess.PIPE,49 encoding="utf-8",50 )51 assert "Usage" in result.stdout
added:tests/test_tutorial/test_options/test_prompt/__init__.py
added:tests/test_tutorial/test_options/test_prompt/test_tutorial001.py+41 added
1import subprocess23import typer4from typer.testing import CliRunner56from options.prompt import tutorial001 as mod78runner = CliRunner()910app = typer.Typer()11app.command()(mod.main)121314def test_option_lastname():15 result = runner.invoke(app, ["Camila", "--lastname", "Gutiérrez"])16 assert result.exit_code == 017 assert "Hello Camila Gutiérrez" in result.output181920def test_option_lastname_prompt():21 result = runner.invoke(app, ["Camila"], input="Gutiérrez")22 assert result.exit_code == 023 assert "Lastname: " in result.output24 assert "Hello Camila Gutiérrez" in result.output252627def test_help():28 result = runner.invoke(app, ["--help"])29 assert result.exit_code == 030 assert "--lastname TEXT" in result.output31 assert "[required]" in result.output323334def test_script():35 result = subprocess.run(36 ["coverage", "run", mod.__file__, "--help"],37 stdout=subprocess.PIPE,38 stderr=subprocess.PIPE,39 encoding="utf-8",40 )41 assert "Usage" in result.stdout
added:tests/test_tutorial/test_options/test_prompt/test_tutorial002.py+41 added
1import subprocess23import typer4from typer.testing import CliRunner56from options.prompt import tutorial002 as mod78runner = CliRunner()910app = typer.Typer()11app.command()(mod.main)121314def test_option_lastname():15 result = runner.invoke(app, ["Camila", "--lastname", "Gutiérrez"])16 assert result.exit_code == 017 assert "Hello Camila Gutiérrez" in result.output181920def test_option_lastname_prompt():21 result = runner.invoke(app, ["Camila"], input="Gutiérrez")22 assert result.exit_code == 023 assert "Please tell me your last name: " in result.output24 assert "Hello Camila Gutiérrez" in result.output252627def test_help():28 result = runner.invoke(app, ["--help"])29 assert result.exit_code == 030 assert "--lastname TEXT" in result.output31 assert "[required]" in result.output323334def test_script():35 result = subprocess.run(36 ["coverage", "run", mod.__file__, "--help"],37 stdout=subprocess.PIPE,38 stderr=subprocess.PIPE,39 encoding="utf-8",40 )41 assert "Usage" in result.stdout
added:tests/test_tutorial/test_options/test_prompt/test_tutorial003.py+50 added
1import subprocess23import typer4from typer.testing import CliRunner56from options.prompt import tutorial003 as mod78runner = CliRunner()910app = typer.Typer()11app.command()(mod.main)121314def test_prompt():15 result = runner.invoke(app, input="Old Project\nOld Project\n")16 assert result.exit_code == 017 assert "Deleting project Old Project" in result.output181920def test_prompt_not_equal():21 result = runner.invoke(22 app, input="Old Project\nNew Spice\nOld Project\nOld Project\n"23 )24 assert result.exit_code == 025 assert "Error: the two entered values do not match" in result.output26 assert "Deleting project Old Project" in result.output272829def test_option():30 result = runner.invoke(app, ["--project-name", "Old Project"])31 assert result.exit_code == 032 assert "Deleting project Old Project" in result.output33 assert "Project name: " not in result.output343536def test_help():37 result = runner.invoke(app, ["--help"])38 assert result.exit_code == 039 assert "--project-name TEXT" in result.output40 assert "[required]" in result.output414243def test_script():44 result = subprocess.run(45 ["coverage", "run", mod.__file__, "--help"],46 stdout=subprocess.PIPE,47 stderr=subprocess.PIPE,48 encoding="utf-8",49 )50 assert "Usage" in result.stdout
added:tests/test_tutorial/test_options/test_required/__init__.py
added:tests/test_tutorial/test_options/test_required/test_tutorial002.py+40 added
1import subprocess23import typer4from typer.testing import CliRunner56from options.required import tutorial001 as mod78runner = CliRunner()910app = typer.Typer()11app.command()(mod.main)121314def test_1():15 result = runner.invoke(app, ["Camila"])16 assert result.exit_code != 017 assert 'Error: Missing option "--lastname".' in result.output181920def test_option_lastname():21 result = runner.invoke(app, ["Camila", "--lastname", "Gutiérrez"])22 assert result.exit_code == 023 assert "Hello Camila Gutiérrez" in result.output242526def test_help():27 result = runner.invoke(app, ["--help"])28 assert result.exit_code == 029 assert "--lastname TEXT" in result.output30 assert "[required]" in result.output313233def test_script():34 result = subprocess.run(35 ["coverage", "run", mod.__file__, "--help"],36 stdout=subprocess.PIPE,37 stderr=subprocess.PIPE,38 encoding="utf-8",39 )40 assert "Usage" in result.stdout
deleted:tests/test_tutorial/test_options/test_tutorial001.py-48 removed
1import subprocess23import typer4from typer.testing import CliRunner56from options import tutorial001 as mod78runner = CliRunner()910app = typer.Typer()11app.command()(mod.main)121314def test_help():15 result = runner.invoke(app, ["--help"])16 assert result.exit_code == 017 assert "Say hi to NAME, optionally with a --lastname." in result.output18 assert "If --formal is used, say hi very formally." in result.output19 assert "Last name of person to greet." in result.output20 assert "Say hi formally." in result.output212223def test_1():24 result = runner.invoke(app, ["Camila"])25 assert result.exit_code == 026 assert "Hello Camila" in result.output272829def test_option_lastname():30 result = runner.invoke(app, ["Camila", "--lastname", "Gutiérrez"])31 assert result.exit_code == 032 assert "Hello Camila Gutiérrez" in result.output333435def test_formal():36 result = runner.invoke(app, ["Camila", "--lastname", "Gutiérrez", "--formal"])37 assert result.exit_code == 038 assert "Good day Ms. Camila Gutiérrez." in result.output394041def test_script():42 result = subprocess.run(43 ["coverage", "run", mod.__file__, "--help"],44 stdout=subprocess.PIPE,45 stderr=subprocess.PIPE,46 encoding="utf-8",47 )48 assert "Usage" in result.stdout
deleted:tests/test_tutorial/test_options/test_tutorial002.py-40 removed
1import subprocess23import typer4from typer.testing import CliRunner56from options import tutorial002 as mod78runner = CliRunner()910app = typer.Typer()11app.command()(mod.main)121314def test_1():15 result = runner.invoke(app, ["Camila"])16 assert result.exit_code != 017 assert 'Error: Missing option "--lastname".' in result.output181920def test_option_lastname():21 result = runner.invoke(app, ["Camila", "--lastname", "Gutiérrez"])22 assert result.exit_code == 023 assert "Hello Camila Gutiérrez" in result.output242526def test_help():27 result = runner.invoke(app, ["--help"])28 assert result.exit_code == 029 assert "--lastname TEXT" in result.output30 assert "[required]" in result.output313233def test_script():34 result = subprocess.run(35 ["coverage", "run", mod.__file__, "--help"],36 stdout=subprocess.PIPE,37 stderr=subprocess.PIPE,38 encoding="utf-8",39 )40 assert "Usage" in result.stdout
deleted:tests/test_tutorial/test_options/test_tutorial003.py-41 removed
1import subprocess23import typer4from typer.testing import CliRunner56from options import tutorial003 as mod78runner = CliRunner()910app = typer.Typer()11app.command()(mod.main)121314def test_option_lastname():15 result = runner.invoke(app, ["Camila", "--lastname", "Gutiérrez"])16 assert result.exit_code == 017 assert "Hello Camila Gutiérrez" in result.output181920def test_option_lastname_prompt():21 result = runner.invoke(app, ["Camila"], input="Gutiérrez")22 assert result.exit_code == 023 assert "Lastname: " in result.output24 assert "Hello Camila Gutiérrez" in result.output252627def test_help():28 result = runner.invoke(app, ["--help"])29 assert result.exit_code == 030 assert "--lastname TEXT" in result.output31 assert "[required]" in result.output323334def test_script():35 result = subprocess.run(36 ["coverage", "run", mod.__file__, "--help"],37 stdout=subprocess.PIPE,38 stderr=subprocess.PIPE,39 encoding="utf-8",40 )41 assert "Usage" in result.stdout
deleted:tests/test_tutorial/test_options/test_tutorial004.py-41 removed
1import subprocess23import typer4from typer.testing import CliRunner56from options import tutorial004 as mod78runner = CliRunner()910app = typer.Typer()11app.command()(mod.main)121314def test_option_lastname():15 result = runner.invoke(app, ["Camila", "--lastname", "Gutiérrez"])16 assert result.exit_code == 017 assert "Hello Camila Gutiérrez" in result.output181920def test_option_lastname_prompt():21 result = runner.invoke(app, ["Camila"], input="Gutiérrez")22 assert result.exit_code == 023 assert "Please tell me your last name: " in result.output24 assert "Hello Camila Gutiérrez" in result.output252627def test_help():28 result = runner.invoke(app, ["--help"])29 assert result.exit_code == 030 assert "--lastname TEXT" in result.output31 assert "[required]" in result.output323334def test_script():35 result = subprocess.run(36 ["coverage", "run", mod.__file__, "--help"],37 stdout=subprocess.PIPE,38 stderr=subprocess.PIPE,39 encoding="utf-8",40 )41 assert "Usage" in result.stdout
deleted:tests/test_tutorial/test_options/test_tutorial005.py-50 removed
1import subprocess23import typer4from typer.testing import CliRunner56from options import tutorial005 as mod78runner = CliRunner()910app = typer.Typer()11app.command()(mod.main)121314def test_prompt():15 result = runner.invoke(app, input="Old Project\nOld Project\n")16 assert result.exit_code == 017 assert "Deleting project Old Project" in result.output181920def test_prompt_not_equal():21 result = runner.invoke(22 app, input="Old Project\nNew Spice\nOld Project\nOld Project\n"23 )24 assert result.exit_code == 025 assert "Error: the two entered values do not match" in result.output26 assert "Deleting project Old Project" in result.output272829def test_option():30 result = runner.invoke(app, ["--project-name", "Old Project"])31 assert result.exit_code == 032 assert "Deleting project Old Project" in result.output33 assert "Project name: " not in result.output343536def test_help():37 result = runner.invoke(app, ["--help"])38 assert result.exit_code == 039 assert "--project-name TEXT" in result.output40 assert "[required]" in result.output414243def test_script():44 result = subprocess.run(45 ["coverage", "run", mod.__file__, "--help"],46 stdout=subprocess.PIPE,47 stderr=subprocess.PIPE,48 encoding="utf-8",49 )50 assert "Usage" in result.stdout
deleted:tests/test_tutorial/test_options/test_tutorial006.py-34 removed
1import subprocess23import typer4from typer.testing import CliRunner56from options import tutorial006 as mod78runner = CliRunner()910app = typer.Typer()11app.command()(mod.main)121314def test_call():15 result = runner.invoke(app)16 assert result.exit_code == 017 assert "Hello Wade Wilson" in result.output181920def test_help():21 result = runner.invoke(app, ["--help"])22 assert result.exit_code == 023 assert "--fullname TEXT" in result.output24 assert "[default: Wade Wilson]" in result.output252627def test_script():28 result = subprocess.run(29 ["coverage", "run", mod.__file__, "--help"],30 stdout=subprocess.PIPE,31 stderr=subprocess.PIPE,32 encoding="utf-8",33 )34 assert "Usage" in result.stdout
modified:typer/params.py+4 added-2 removed
104 unmodified lines
105106def Argument(107 # Parameter108 default: Optional[Any],109 *param_decls: str,109 *,110 callback: Optional[Callable[[click.Context, click.Parameter, str], Any]] = None,111 metavar: Optional[str] = None,112 expose_value: bool = True,113 is_eager: bool = False,
27 unmodified lines
141) -> Any:142 return ArgumentInfo(143 # Parameter144 default=default,145 # Arguments can only have one param declaration146 # it will be generated from the param name145 param_decls=param_decls,147 param_decls=None,148 callback=callback,149 metavar=metavar,150 expose_value=expose_value,151 is_eager=is_eager,
26 unmodified lines
modified:mkdocs.yml+13 added-2 removed
21 unmodified lines
22 - Features: 'features.md'23 - Tutorial - User Guide:24 - Tutorial - User Guide - Intro: 'tutorial/index.md'25 - First Steps: 'tutorial/first-steps.md'26 - CLI Options: 'tutorial/options.md'26 - CLI Arguments: 'tutorial/arguments.md'28 - Commands: 'tutorial/commands.md'27 - CLI Options:28 - CLI Options Intro: 'tutorial/options/index.md'29 - CLI Options with Help: 'tutorial/options/help.md'30 - Required CLI Options: 'tutorial/options/required.md'31 - CLI Option Prompt: 'tutorial/options/prompt.md'32 - CLI Option Name: 'tutorial/options/name.md'33 - Commands:34 - Commands Intro: 'tutorial/commands/index.md'35 - Command CLI Arguments: 'tutorial/commands/arguments.md'36 - Command CLI Options: 'tutorial/commands/options.md'37 - Command Help: 'tutorial/commands/help.md'38 - Custom Command Name: 'tutorial/commands/name.md'39 - One or Multiple Commands: 'tutorial/commands/one-or-multiple.md'40 - CLI Parameter Types:41 - CLI Parameter Types Intro: 'tutorial/parameter-types/index.md'42 - Number: 'tutorial/parameter-types/number.md'43 - UUID: 'tutorial/parameter-types/uuid.md'
42 unmodified lines