clan-config: add option --quiet
All checks were successful
build / test (pull_request) Successful in 25s
All checks were successful
build / test (pull_request) Successful in 25s
This commit is contained in:
parent
999fbe0d89
commit
b16f314c80
@ -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",
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user