Skip to content

Commit

Permalink
Bump version, fix subcommand example docs/comments
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Oct 11, 2024
1 parent 80b1316 commit 2df6aa1
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
Decorator-based Subcommands
==========================================

:func:`tyro.extras.app.command()` and :func:`tyro.extras.app.cli()` provide a
decorator-based API for subcommands, which is inspired by `click
<https://click.palletsprojects.com/>`_.
:func:`tyro.extras.SubcommandApp()` provides a decorator-based API for
subcommands, which is inspired by `click <https://click.palletsprojects.com/>`_.


.. code-block:: python
Expand Down
5 changes: 2 additions & 3 deletions examples/04_additional/15_decorator_subcommands.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""Decorator-based Subcommands
:func:`tyro.extras.app.command()` and :func:`tyro.extras.app.cli()` provide a
decorator-based API for subcommands, which is inspired by `click
<https://click.palletsprojects.com/>`_.
:func:`tyro.extras.SubcommandApp()` provides a decorator-based API for
subcommands, which is inspired by `click <https://click.palletsprojects.com/>`_.
Usage:
`python my_script.py --help`
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "tyro"
authors = [
{name = "brentyi", email = "[email protected]"},
]
version = "0.8.11" # TODO: currently needs to be synchronized manually with __init__.py.
version = "0.8.12" # TODO: currently needs to be synchronized manually with __init__.py.
description = "Strongly typed, zero-effort CLI interfaces"
readme = "README.md"
license = { text="MIT" }
Expand Down
2 changes: 1 addition & 1 deletion src/tyro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@


# TODO: this should be synchronized automatically with the pyproject.toml.
__version__ = "0.8.11"
__version__ = "0.8.12"
2 changes: 1 addition & 1 deletion src/tyro/extras/_subcommand_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def cli(
description: Optional[str] = None,
args: Optional[Sequence[str]] = None,
use_underscores: bool = False,
sort_subcommands: bool = True,
sort_subcommands: bool = False,
) -> Any:
"""Run the command-line interface.
Expand Down
6 changes: 3 additions & 3 deletions tests/test_decorator_subcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def add(a: int, b: int) -> None:
def test_app_just_one_cli(capsys):
# Test: `python my_script.py --help`
with pytest.raises(SystemExit):
app_just_one.cli(args=["--help"], sort_subcommands=False)
app_just_one.cli(args=["--help"])
captured = capsys.readouterr()
assert "usage: " in captured.out
assert "greet" not in captured.out
Expand All @@ -44,13 +44,13 @@ def test_app_cli(capsys):

# Test: `python my_script.py greet --help`
with pytest.raises(SystemExit):
app.cli(args=["greet", "--help"])
app.cli(args=["greet", "--help"], sort_subcommands=False)
captured = capsys.readouterr()
assert "usage: " in captured.out
assert "Greet someone." in captured.out

# Test: `python my_script.py greet --name Alice`
app.cli(args=["greet", "--name", "Alice"])
app.cli(args=["greet", "--name", "Alice"], sort_subcommands=True)
captured = capsys.readouterr()
assert captured.out.strip() == "Hello, Alice!"

Expand Down

0 comments on commit 2df6aa1

Please sign in to comment.