Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 Update docs example for a Typer/Click group to make new subcommands explicit #755

Merged
merged 1 commit into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading