fix: Ensure quiet is a flag on the cli

We regressed quiet into requiring a value to be set as a cli option
(`--quiet=true`) instead of just functioning as a flag (`--quiet`). This
change restores the previous interface on the command line,
and adds a test to ensure no regressions.
This commit is contained in:
Marty Oehme 2025-11-29 11:18:48 +01:00
parent e50fc9444a
commit 1ea149c1de
Signed by: Marty
GPG key ID: 4E535BC19C61886E
2 changed files with 23 additions and 2 deletions

View file

@ -29,6 +29,17 @@ class TestCli:
"notes_annot": "HERENOTE",
}
def test_cli_notes_quiet_is_flag(self, monkeypatch):
monkeypatch.setattr(
"sys.argv",
[
"topen",
"123",
"--quiet",
],
)
assert parse_cli()["notes_quiet"] is True
def test_cli_parses_paths(self, monkeypatch):
monkeypatch.setattr(
"sys.argv",

View file

@ -132,7 +132,7 @@ class Opt:
metavar: str | None = None
cast: type | Callable = str
help_text: str = ""
flag: bool = False
is_flag: bool = False
def _real_path(p: Path | str) -> Path:
@ -224,7 +224,8 @@ OPTIONS: dict[str, Opt] = {
"notes.quiet",
default=False,
cast=_strtobool,
help_text="Silence any verbose displayed information",
help_text="Silence any verbosely displayed information",
is_flag=True,
),
}
@ -321,6 +322,15 @@ you view the task.
for key, opt in OPTIONS.items():
if opt.cli is None:
continue
if opt.is_flag:
parser.add_argument(
*opt.cli,
dest=key,
help=opt.help_text,
default=None,
action="store_true",
)
continue
parser.add_argument(
*opt.cli,
dest=key,