diff --git a/src/python/jw/pkg/lib/util.py b/src/python/jw/pkg/lib/util.py index f6fd3352..119ece1b 100644 --- a/src/python/jw/pkg/lib/util.py +++ b/src/python/jw/pkg/lib/util.py @@ -81,16 +81,22 @@ async def run_cmd( if not ret: return ret collector.append(ret) - if verbose: - __log(NOTICE, ret.decode(enc_for_verbose, errors="replace").rstrip("\n")) return ret return _read + interactive = ( + cmd_input == "mode:interactive" + or (cmd_input == "mode:auto" and sys.stdin.isatty()) + ) + if verbose: delim_len = 120 delim = title if title is not None else f'---- Running {pretty_cmd(args, wd)} -' - delim += '-' * max(0, delim_len - len(delim)) - log(NOTICE, ',' + delim + ' >') + if interactive: + log(NOTICE, delim) + else: + delim += '-' * max(0, delim_len - len(delim)) + log(NOTICE, ',' + delim + ' >') cwd: str|None = None if wd is not None: @@ -100,10 +106,8 @@ async def run_cmd( try: # -- interactive mode - if cmd_input == "mode:auto" and sys.stdin.isatty(): - cmd_input = "mode:interactive" - if cmd_input == "mode:interactive": + if interactive: import pty @@ -219,7 +223,7 @@ async def run_cmd( finally: if cwd is not None: os.chdir(cwd) - if verbose: + if verbose and not interactive: log(NOTICE, '`' + delim + ' <') async def run_curl(args: list[str], parse_json: bool=True, wd=None, throw=None, verbose=False, cmd_input=None) -> dict|str: # export