diff --git a/docs/source/examples/04_additional/15_decorator_subcommands.rst b/docs/source/examples/04_additional/15_decorator_subcommands.rst index 5b8b5f50..1def51af 100644 --- a/docs/source/examples/04_additional/15_decorator_subcommands.rst +++ b/docs/source/examples/04_additional/15_decorator_subcommands.rst @@ -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 -`_. +:func:`tyro.extras.SubcommandApp()` provides a decorator-based API for +subcommands, which is inspired by `click `_. .. code-block:: python diff --git a/examples/04_additional/15_decorator_subcommands.py b/examples/04_additional/15_decorator_subcommands.py index 466b9a78..e9fc77cc 100644 --- a/examples/04_additional/15_decorator_subcommands.py +++ b/examples/04_additional/15_decorator_subcommands.py @@ -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 -`_. +:func:`tyro.extras.SubcommandApp()` provides a decorator-based API for +subcommands, which is inspired by `click `_. Usage: `python my_script.py --help` diff --git a/pyproject.toml b/pyproject.toml index 6191a611..71bdffb8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "tyro" authors = [ {name = "brentyi", email = "brentyi@berkeley.edu"}, ] -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" } diff --git a/src/tyro/__init__.py b/src/tyro/__init__.py index f876eab0..7fd0b182 100644 --- a/src/tyro/__init__.py +++ b/src/tyro/__init__.py @@ -14,4 +14,4 @@ # TODO: this should be synchronized automatically with the pyproject.toml. -__version__ = "0.8.11" +__version__ = "0.8.12" diff --git a/src/tyro/extras/_subcommand_app.py b/src/tyro/extras/_subcommand_app.py index 0a8a906f..f5497188 100644 --- a/src/tyro/extras/_subcommand_app.py +++ b/src/tyro/extras/_subcommand_app.py @@ -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. diff --git a/tests/test_decorator_subcommands.py b/tests/test_decorator_subcommands.py index 422819d1..0ed47227 100644 --- a/tests/test_decorator_subcommands.py +++ b/tests/test_decorator_subcommands.py @@ -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 @@ -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!"