diff --git a/pkgs/clan-cli/clan_cli/config/__init__.py b/pkgs/clan-cli/clan_cli/config/__init__.py index fee0f332..ff2b9c63 100644 --- a/pkgs/clan-cli/clan_cli/config/__init__.py +++ b/pkgs/clan-cli/clan_cli/config/__init__.py @@ -124,6 +124,7 @@ def process_args( value: Any, options: dict, settings_file: Path, + quiet: bool = False, option_description: str = "", ) -> None: if value == []: @@ -144,6 +145,7 @@ def process_args( value={attr: value}, options=options, settings_file=settings_file, + quiet=quiet, option_description=option, ) @@ -170,9 +172,10 @@ def process_args( new_config = merge(current_config, result) with open(settings_file, "w") as f: json.dump(new_config, f, indent=2) - new_value = read_option(option) - print(f"New Value for {option}:") - print(new_value) + if not quiet: + new_value = read_option(option) + print(f"New Value for {option}:") + print(new_value) def register_parser( @@ -218,10 +221,19 @@ def _register_parser( option=args.option, value=args.value, options=options, + quiet=args.quiet, settings_file=args.settings_file, ) ) + # add --quiet option + parser.add_argument( + "--quiet", + "-q", + help="Suppress output", + action="store_true", + ) + # add argument to pass output file parser.add_argument( "--settings-file", diff --git a/pkgs/clan-cli/tests/test_config.py b/pkgs/clan-cli/tests/test_config.py index ab4e6349..b573077b 100644 --- a/pkgs/clan-cli/tests/test_config.py +++ b/pkgs/clan-cli/tests/test_config.py @@ -29,7 +29,6 @@ example_options = f"{Path(config.__file__).parent}/jsonschema/options.json" def test_set_some_option( argv: list[str], expected: dict[str, Any], - capsys: pytest.CaptureFixture, monkeypatch: pytest.MonkeyPatch, ) -> None: # monkeypatch sys.argv @@ -37,7 +36,9 @@ def test_set_some_option( with tempfile.NamedTemporaryFile() as out_file: with open(out_file.name, "w") as f: json.dump({}, f) - monkeypatch.setattr(sys, "argv", ["", "--settings-file", out_file.name] + argv) + monkeypatch.setattr( + sys, "argv", ["", "--quiet", "--settings-file", out_file.name] + argv + ) parser = argparse.ArgumentParser() config._register_parser( parser=parser,