Skip to content

Commit 2df6aa1

Browse files
committed
Bump version, fix subcommand example docs/comments
1 parent 80b1316 commit 2df6aa1

File tree

6 files changed

+10
-12
lines changed

6 files changed

+10
-12
lines changed

docs/source/examples/04_additional/15_decorator_subcommands.rst

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
Decorator-based Subcommands
55
==========================================
66

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

1110

1211
.. code-block:: python

examples/04_additional/15_decorator_subcommands.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
"""Decorator-based Subcommands
22
3-
:func:`tyro.extras.app.command()` and :func:`tyro.extras.app.cli()` provide a
4-
decorator-based API for subcommands, which is inspired by `click
5-
<https://click.palletsprojects.com/>`_.
3+
:func:`tyro.extras.SubcommandApp()` provides a decorator-based API for
4+
subcommands, which is inspired by `click <https://click.palletsprojects.com/>`_.
65
76
Usage:
87
`python my_script.py --help`

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "tyro"
77
authors = [
88
{name = "brentyi", email = "[email protected]"},
99
]
10-
version = "0.8.11" # TODO: currently needs to be synchronized manually with __init__.py.
10+
version = "0.8.12" # TODO: currently needs to be synchronized manually with __init__.py.
1111
description = "Strongly typed, zero-effort CLI interfaces"
1212
readme = "README.md"
1313
license = { text="MIT" }

src/tyro/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515

1616
# TODO: this should be synchronized automatically with the pyproject.toml.
17-
__version__ = "0.8.11"
17+
__version__ = "0.8.12"

src/tyro/extras/_subcommand_app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def cli(
9191
description: Optional[str] = None,
9292
args: Optional[Sequence[str]] = None,
9393
use_underscores: bool = False,
94-
sort_subcommands: bool = True,
94+
sort_subcommands: bool = False,
9595
) -> Any:
9696
"""Run the command-line interface.
9797

tests/test_decorator_subcommands.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def add(a: int, b: int) -> None:
2525
def test_app_just_one_cli(capsys):
2626
# Test: `python my_script.py --help`
2727
with pytest.raises(SystemExit):
28-
app_just_one.cli(args=["--help"], sort_subcommands=False)
28+
app_just_one.cli(args=["--help"])
2929
captured = capsys.readouterr()
3030
assert "usage: " in captured.out
3131
assert "greet" not in captured.out
@@ -44,13 +44,13 @@ def test_app_cli(capsys):
4444

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

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

0 commit comments

Comments
 (0)