Skip to content

Commit

Permalink
📝 Update docs example for a Typer/Click group to make new subcommands…
Browse files Browse the repository at this point in the history
… explicit (#755)
  • Loading branch information
svlandeg authored Mar 23, 2024
1 parent a0889ed commit 0440d9a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 9 additions & 2 deletions docs/tutorial/using-click.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,19 @@ Check it:
<div class="termy">

```console
$ python main.py
$ python main.py --help

// Notice we have both subcommands, top and hello
Usage: main.py [OPTIONS] COMMAND [ARGS]...

Error: Missing command.
Options:
--install-completion Install completion for the current shell.
--show-completion Show completion for the current shell, to copy it or customize the installation.
--help Show this message and exit.

Commands:
hello
top

// Call the Typer part
$ python main.py top
Expand Down
8 changes: 8 additions & 0 deletions tests/test_tutorial/test_using_click/test_tutorial003.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ def test_cli():
assert "Missing command" in result.stdout or "Usage" in result.stdout


def test_help():
result = runner.invoke(mod.typer_click_object, ["--help"])
assert result.exit_code == 0
assert "Commands" in result.output
assert "top" in result.output
assert "hello" in result.output


def test_typer():
result = runner.invoke(mod.typer_click_object, ["top"])
assert "The Typer app is at the top level" in result.stdout
Expand Down

0 comments on commit 0440d9a

Please sign in to comment.