App: Support --verbose

Add the --verbose global option, which is made available as the
App.verbose property.

Some functions still take a verbose parameter, but the type of these
parameters is converted from bool to bool|None.  The idea is that, if
they are None, their verbosity falls back to the global default.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-03-06 16:50:27 +01:00
commit 67a2931f5e
5 changed files with 28 additions and 11 deletions

View file

@ -212,6 +212,7 @@ class App(Base):
# -- Members without default values
self.__opt_os: str|None = None
self.__opt_interactive: bool|None = None
self.__opt_verbose: bool|None = None
self.__top_name: str|None = None
self.__os_release: str|None = None
self.__distro_id: str|None = None
@ -238,6 +239,7 @@ class App(Base):
parser.add_argument('-O', '--os', default = None, help='Target operating system')
parser.add_argument('--distro-id', default=None, help='Distribution ID (default is taken from /etc/os-release)')
parser.add_argument('--interactive', choices=['true', 'false', 'auto'], default='true', help="Wait for user input or try to proceed unattended")
parser.add_argument('--verbose', action='store_true', default=False, help="Be verbose on stderr about what's being done on the distro level")
async def _run(self, args: argparse.Namespace) -> None:
self.__opt_os = args.os
@ -265,11 +267,17 @@ class App(Base):
self.__opt_interactive = sys.stdin.isatty()
return self.__opt_interactive
@property
def verbose(self) -> bool:
if self.__opt_verbose is None:
self.__opt_verbose = self.args.verbose
return self.__opt_verbose
@property
def exec_context(self) -> str:
if self.__exec_context is None:
from .lib.ec.Local import Local
self.__exec_context = Local(interactive=self.interactive)
self.__exec_context = Local(interactive=self.interactive, verbose_default=self.verbose)
return self.__exec_context
@property