diff --git a/src/algokit/cli/goal.py b/src/algokit/cli/goal.py index 6a1e9c43..4bddfc19 100644 --- a/src/algokit/cli/goal.py +++ b/src/algokit/cli/goal.py @@ -8,14 +8,14 @@ @click.command( "goal", - short_help="Run the Algorand goal CLI against the AlgoKit Sandbox", + short_help="Run the Algorand goal CLI against the AlgoKit Sandbox.", context_settings={ "ignore_unknown_options": True, }, ) @click.option( "--console/--no-console", - help="Open a Bash console so you can execute multiple goal commands and/or interact with a filesystem", + help="Open a Bash console so you can execute multiple goal commands and/or interact with a filesystem.", default=False, ) @click.argument("goal_args", nargs=-1, type=click.UNPROCESSED) diff --git a/src/algokit/cli/init.py b/src/algokit/cli/init.py index 0c721bee..6ab155fb 100644 --- a/src/algokit/cli/init.py +++ b/src/algokit/cli/init.py @@ -42,7 +42,7 @@ def _get_blessed_templates() -> dict[str, str]: "--template", type=DeferredChoice(lambda: list(_get_blessed_templates())), default=None, - help="Name of an official template to use", + help="Name of an official template to use.", ) @click.option( "--template-url", @@ -61,7 +61,7 @@ def _get_blessed_templates() -> dict[str, str]: @click.option( "--defaults", default=None, - help="Automatically choose default answers without asking when creating this template", + help="Automatically choose default answers without asking when creating this template.", is_flag=True, ) @click.option( diff --git a/src/algokit/cli/sandbox.py b/src/algokit/cli/sandbox.py index ecaf2aca..04bf31d5 100644 --- a/src/algokit/cli/sandbox.py +++ b/src/algokit/cli/sandbox.py @@ -9,7 +9,7 @@ logger = logging.getLogger(__name__) -@click.group("sandbox", short_help="Manage the AlgoKit sandbox") +@click.group("sandbox", short_help="Manage the AlgoKit sandbox.") def sandbox_group() -> None: try: compose_version_result = proc.run( @@ -48,7 +48,7 @@ def sandbox_group() -> None: proc.run(["docker", "version"], bad_return_code_error_message="Docker engine isn't running; please start it.") -@sandbox_group.command("start", short_help="Start the AlgoKit Sandbox") +@sandbox_group.command("start", short_help="Start the AlgoKit Sandbox.") def start_sandbox() -> None: sandbox = ComposeSandbox() compose_file_status = sandbox.compose_file_status() @@ -62,7 +62,7 @@ def start_sandbox() -> None: sandbox.up() -@sandbox_group.command("stop", short_help="Stop the AlgoKit Sandbox") +@sandbox_group.command("stop", short_help="Stop the AlgoKit Sandbox.") def stop_sandbox() -> None: sandbox = ComposeSandbox() compose_file_status = sandbox.compose_file_status() @@ -72,7 +72,7 @@ def stop_sandbox() -> None: sandbox.stop() -@sandbox_group.command("reset", short_help="Reset the AlgoKit Sandbox") +@sandbox_group.command("reset", short_help="Reset the AlgoKit Sandbox.") @click.option( "--update/--no-update", default=True, @@ -97,7 +97,7 @@ def reset_sandbox(update: bool) -> None: # noqa: FBT001 SERVICE_NAMES = ("algod", "indexer", "indexer-db") -@sandbox_group.command("status", short_help="Check the status of the AlgoKit Sandbox") +@sandbox_group.command("status", short_help="Check the status of the AlgoKit Sandbox.") def sandbox_status() -> None: sandbox = ComposeSandbox() ps = sandbox.ps() @@ -134,7 +134,7 @@ def sandbox_status() -> None: @sandbox_group.command( "console", short_help="Run the Algorand goal CLI against the AlgoKit Sandbox via a Bash console" - + " so you can execute multiple goal commands and/or interact with a filesystem", + + " so you can execute multiple goal commands and/or interact with a filesystem.", ) @click.pass_context def sandbox_console(context: click.Context) -> None: diff --git a/src/algokit/core/log_handlers.py b/src/algokit/core/log_handlers.py index e2de4c35..b536155f 100644 --- a/src/algokit/core/log_handlers.py +++ b/src/algokit/core/log_handlers.py @@ -136,7 +136,7 @@ def _set_force_styles_to(ctx: click.Context, _param: click.Option, value: bool | is_flag=True, callback=_set_verbose, expose_value=False, - help="Enable logging of DEBUG messages to the console", + help="Enable logging of DEBUG messages to the console.", ) color_option = click.option( @@ -145,5 +145,5 @@ def _set_force_styles_to(ctx: click.Context, _param: click.Option, value: bool | default=lambda: False if os.getenv("NO_COLOR") else None, callback=_set_force_styles_to, expose_value=False, - help="Force enable or disable of console output styling", + help="Force enable or disable of console output styling.", ) diff --git a/tests/goal/test_goal.py b/tests/goal/test_goal.py index dd8bc3d9..e110b9e0 100644 --- a/tests/goal/test_goal.py +++ b/tests/goal/test_goal.py @@ -1,13 +1,19 @@ from subprocess import CompletedProcess from pytest_mock import MockerFixture -from utils.app_dir_mock import AppDirs from utils.approvals import verify from utils.click_invoker import invoke from utils.proc_mock import ProcMock -def test_goal_no_args(app_dir_mock: AppDirs, proc_mock: ProcMock): +def test_goal_help(): + result = invoke("goal -h") + + assert result.exit_code == 0 + verify(result.output) + + +def test_goal_no_args(proc_mock: ProcMock, mocker: MockerFixture): result = invoke("goal") assert result.exit_code == 0 diff --git a/tests/goal/test_goal.test_goal_help.approved.txt b/tests/goal/test_goal.test_goal_help.approved.txt new file mode 100644 index 00000000..af4e7a5a --- /dev/null +++ b/tests/goal/test_goal.test_goal_help.approved.txt @@ -0,0 +1,6 @@ +Usage: algokit goal [OPTIONS] [GOAL_ARGS]... + +Options: + --console / --no-console Open a Bash console so you can execute multiple goal + commands and/or interact with a filesystem. + -h, --help Show this message and exit. diff --git a/tests/init/test_init.py b/tests/init/test_init.py index 16946c01..0fe32071 100644 --- a/tests/init/test_init.py +++ b/tests/init/test_init.py @@ -40,6 +40,13 @@ def set_blessed_templates(mocker: MockerFixture): } +def test_init_help(): + result = invoke("init -h") + + assert result.exit_code == 0 + verify(result.output) + + def test_init_no_interaction_required_no_git_no_network( tmp_path_factory: TempPathFactory, mock_questionary_input: PipeInput ): diff --git a/tests/init/test_init.test_init_help.approved.txt b/tests/init/test_init.test_init_help.approved.txt new file mode 100644 index 00000000..460ef7d7 --- /dev/null +++ b/tests/init/test_init.test_init_help.approved.txt @@ -0,0 +1,17 @@ +Usage: algokit init [OPTIONS] + + Initializes a new project from a template. + +Options: + --name TEXT Name of the directory / repository to create. + --template [simple|beaker] Name of an official template to use. + --template-url URL URL to a git repo with a custom project template. + --accept-template-url Accept the specified template URL, acknowledging + the security implications of an unofficial + template. + --git / --no-git Initialise git repository in directory after + creation. + --defaults Automatically choose default answers without + asking when creating this template. + -a, --answer Answers key/value pairs to pass to the template. + -h, --help Show this message and exit. diff --git a/tests/sandbox/test_sandbox.py b/tests/sandbox/test_sandbox.py new file mode 100644 index 00000000..f482568e --- /dev/null +++ b/tests/sandbox/test_sandbox.py @@ -0,0 +1,9 @@ +from approvaltests import verify # type: ignore +from utils.click_invoker import invoke + + +def test_sandbox_help(): + result = invoke("sandbox -h") + + assert result.exit_code == 0 + verify(result.output) diff --git a/tests/sandbox/test_sandbox.test_sandbox_help.approved.txt b/tests/sandbox/test_sandbox.test_sandbox_help.approved.txt new file mode 100644 index 00000000..a6e54bdb --- /dev/null +++ b/tests/sandbox/test_sandbox.test_sandbox_help.approved.txt @@ -0,0 +1,13 @@ +Usage: algokit sandbox [OPTIONS] COMMAND [ARGS]... + +Options: + -h, --help Show this message and exit. + +Commands: + console Run the Algorand goal CLI against the AlgoKit Sandbox via a Bash + console so you can execute multiple goal commands and/or interact + with a filesystem. + reset Reset the AlgoKit Sandbox. + start Start the AlgoKit Sandbox. + status Check the status of the AlgoKit Sandbox. + stop Stop the AlgoKit Sandbox. diff --git a/tests/test_root.py b/tests/test_root.py new file mode 100644 index 00000000..77b745d0 --- /dev/null +++ b/tests/test_root.py @@ -0,0 +1,9 @@ +from approvaltests import verify # type: ignore +from utils.click_invoker import invoke + + +def test_help(): + result = invoke("-h") + + assert result.exit_code == 0 + verify(result.output) diff --git a/tests/test_root.test_help.approved.txt b/tests/test_root.test_help.approved.txt new file mode 100644 index 00000000..c0f10a29 --- /dev/null +++ b/tests/test_root.test_help.approved.txt @@ -0,0 +1,15 @@ +Usage: algokit [OPTIONS] COMMAND [ARGS]... + + AlgoKit is your one-stop shop to develop applications on the Algorand + blockchain. + +Options: + --version Show the version and exit. + -v, --verbose Enable logging of DEBUG messages to the console. + --color / --no-color Force enable or disable of console output styling. + -h, --help Show this message and exit. + +Commands: + goal Run the Algorand goal CLI against the AlgoKit Sandbox. + init Initializes a new project. + sandbox Manage the AlgoKit sandbox.