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

@ -31,14 +31,18 @@ def pretty_cmd(cmd: list[str], wd=None):
ret += f' in {wd}'
return ret
# See ec.Local.run() for what this function does
async def run_cmd(*args, ec: ExecContext|None=None, **kwargs) -> tuple[str|bytes|None, str|bytes|None]:
# See ExecContext.run() for what this function does
async def run_cmd(*args, ec: ExecContext|None=None, verbose: bool|None=None, **kwargs) -> tuple[str|bytes|None, str|bytes|None]:
if verbose is None:
verbose = False if ec is None else ec.verbose_default
if ec is None:
from .ec.Local import Local
ec = Local()
return await ec.run(*args, **kwargs)
ec = Local(verbose_default=verbose)
return await ec.run(verbose=verbose, *args, **kwargs)
async def run_curl(args: list[str], parse_json: bool=True, wd=None, throw=None, verbose=False, cmd_input=None, ec: ExecContext|None=None) -> dict|str: # export
async def run_curl(args: list[str], parse_json: bool=True, wd=None, throw=None, verbose=None, cmd_input=None, ec: ExecContext|None=None) -> dict|str: # export
if verbose is None:
verbose = False if ec is None else ec.verbose_default
cmd = ['curl']
if not verbose:
cmd.append('-s')