From 449d448d05ccce4150f61048c2dc2005608aea15 Mon Sep 17 00:00:00 2001 From: MaxymVlasov Date: Fri, 3 Jan 2025 12:52:00 +0200 Subject: [PATCH] Improve naming and help output --- src/pre_commit_terraform/_cli_parsing.py | 3 +++ tests/pytest/test__cli_parsing.py | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/pre_commit_terraform/_cli_parsing.py b/src/pre_commit_terraform/_cli_parsing.py index 2b18c6508..3beb32f47 100644 --- a/src/pre_commit_terraform/_cli_parsing.py +++ b/src/pre_commit_terraform/_cli_parsing.py @@ -27,6 +27,7 @@ def populate_common_argument_parser(parser: ArgumentParser) -> None: '-h', '--hook-config', action='append', + metavar='KEY=VALUE', help='Arguments that configure hook behavior', default=[], ) @@ -42,6 +43,8 @@ def populate_common_argument_parser(parser: ArgumentParser) -> None: '-e', '--env-vars', '--envs', + dest='env_vars_strs', + metavar='KEY=VALUE', action='append', help='Setup additional Environment Variables during hook execution', default=[], diff --git a/tests/pytest/test__cli_parsing.py b/tests/pytest/test__cli_parsing.py index 61b8ebcf5..58ba1ea5e 100644 --- a/tests/pytest/test__cli_parsing.py +++ b/tests/pytest/test__cli_parsing.py @@ -20,7 +20,7 @@ def test_populate_common_argument_parser(mocker): assert args.args == ['arg1'] assert args.hook_config == ['hook1'] assert args.tf_init_args == ['init1'] - assert args.env_vars == ['env1'] + assert args.env_vars_strs == ['env1'] assert args.files == ['file1', 'file2'] @@ -32,7 +32,7 @@ def test_populate_common_argument_parser_defaults(mocker): assert args.args == [] assert args.hook_config == [] assert args.tf_init_args == [] - assert args.env_vars == [] + assert args.env_vars_strs == [] assert args.files == [] @@ -65,7 +65,7 @@ def test_populate_common_argument_parser_multiple_values(mocker): assert args.args == ['arg1', 'arg2'] assert args.hook_config == ['hook1', 'hook2'] assert args.tf_init_args == ['init1', 'init2'] - assert args.env_vars == ['env1', 'env2'] + assert args.env_vars_strs == ['env1', 'env2'] assert args.files == ['file1', 'file2'] @@ -91,7 +91,7 @@ def test_attach_subcommand_parsers_to(mocker): assert args.args == ['arg1'] assert args.hook_config == ['hook1'] assert args.tf_init_args == ['init1'] - assert args.env_vars == ['env1'] + assert args.env_vars_strs == ['env1'] assert args.files == ['file1', 'file2'] assert args.invoke_cli_app == mock_subcommand_module.invoke_cli_app @@ -168,7 +168,7 @@ def test_initialize_argument_parser(mocker): assert args.args == ['arg1'] assert args.hook_config == ['hook1'] assert args.tf_init_args == ['init1'] - assert args.env_vars == ['env1'] + assert args.env_vars_strs == ['env1'] assert args.files == ['file1', 'file2'] assert args.invoke_cli_app == mock_subcommand_module.invoke_cli_app