From 3aebfc8294b2134fb1a74c136667c81ac4930683 Mon Sep 17 00:00:00 2001 From: GHPS Date: Thu, 15 Jul 2021 23:52:06 +0200 Subject: [PATCH 1/2] Support -h help option to add user friendliness (and follow the de-facto standard) --- tmuxp/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmuxp/cli.py b/tmuxp/cli.py index 72699f8f8c..e332c204b0 100644 --- a/tmuxp/cli.py +++ b/tmuxp/cli.py @@ -749,7 +749,7 @@ def load_workspace( return _setup_plugins(builder) -@click.group(context_settings={'obj': {}}) +@click.group(context_settings={'obj': {}, 'help_option_names':['-h', '--help']}) @click.version_option(__version__, '-V', '--version', message='%(prog)s %(version)s') @click.option( '--log-level', From 7adbadc21ddffc23836896739729edcbf8adb75e Mon Sep 17 00:00:00 2001 From: GHPS Date: Thu, 15 Jul 2021 23:55:00 +0200 Subject: [PATCH 2/2] Tests for help CLI options (--help and -h) --- tests/test_cli.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index 8a06b723f7..17d69cbcdd 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -761,6 +761,18 @@ def test_import(cli_args, monkeypatch): assert 'tmuxinator' in result.output assert 'teamocil' in result.output +@pytest.mark.parametrize( + "cli_args", + [ + (['--help']), + (['-h']), + ], +) +def test_help(cli_args, monkeypatch): + runner = CliRunner() + + result = runner.invoke(cli.cli, cli_args) + assert 'Usage: cli [OPTIONS] COMMAND [ARGS]...' in result.output @pytest.mark.parametrize( "cli_args,inputs",