1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-09-06 05:08:42 +02:00

Use Field.get_callback to handle quiet/verbose and http_debug/http_full_debug options

This commit is contained in:
2024-01-24 09:49:24 +01:00
parent 8a38a9da82
commit c7af0e458f
2 changed files with 33 additions and 2 deletions

View File

@@ -564,7 +564,7 @@ class Options(OscOptions):
description=textwrap.dedent(
"""
Reduce amount of printed information to bare minimum.
Takes priority over ``verbose``.
If enabled, automatically sets ``verbose`` to ``False``.
"""
),
) # type: ignore[assignment]
@@ -574,8 +574,10 @@ class Options(OscOptions):
description=textwrap.dedent(
"""
Increase amount of printed information to stdout.
Automatically set to ``False`` when ``quiet`` is enabled.
"""
),
get_callback=lambda conf, value: False if conf.quiet else value,
) # type: ignore[assignment]
debug: bool = Field(
@@ -592,8 +594,10 @@ class Options(OscOptions):
description=textwrap.dedent(
"""
Print HTTP traffic to stderr.
Automatically set to ``True`` when``http_full_debug`` is enabled.
"""
),
get_callback=lambda conf, value: True if conf.http_full_debug else value,
) # type: ignore[assignment]
http_full_debug: bool = Field(
@@ -601,6 +605,7 @@ class Options(OscOptions):
description=textwrap.dedent(
"""
[CAUTION!] Print HTTP traffic incl. authentication data to stderr.
If enabled, automatically sets ``http_debug`` to ``True``.
"""
),
) # type: ignore[assignment]
@@ -1821,7 +1826,6 @@ def get_config(override_conffile=None,
overrides["http_debug"] = override_http_debug
if override_http_full_debug is not None:
overrides["http_debug"] = override_http_full_debug or overrides["http_debug"]
overrides["http_full_debug"] = override_http_full_debug
if override_traceback is not None: