diff --git a/src/decman/__init__.py b/src/decman/__init__.py index 14cde92..3b9dc11 100644 --- a/src/decman/__init__.py +++ b/src/decman/__init__.py @@ -120,8 +120,7 @@ def prg( if code != 0: output.print_warning(f"Command '{shlex.join(cmd)}' returned with an exit code {code}.") if not pty: - for line in command_output.strip().split("\n"): - output.print_continuation(line.strip()) + output.print_command_output(command_output) return command_output diff --git a/src/decman/app.py b/src/decman/app.py index 34bd2c0..b236114 100644 --- a/src/decman/app.py +++ b/src/decman/app.py @@ -84,6 +84,7 @@ def main(): failed = True except errors.CommandFailedError as error: output.print_error(str(error)) + output.print_command_output(error.output) output.print_traceback() failed = True except ValueError as error: diff --git a/src/decman/core/error.py b/src/decman/core/error.py index 218ba15..f1ac710 100644 --- a/src/decman/core/error.py +++ b/src/decman/core/error.py @@ -68,4 +68,4 @@ class CommandFailedError(Exception): def __init__(self, command: list[str], output: str) -> None: self.command = shlex.join(command) self.output = output.strip() - super().__init__(f"Running a command '{self.command}' failed. Output:\n{self.output}") + super().__init__(f"Running a command '{self.command}' failed.") diff --git a/src/decman/core/output.py b/src/decman/core/output.py index a36267e..f355907 100644 --- a/src/decman/core/output.py +++ b/src/decman/core/output.py @@ -133,12 +133,12 @@ def print_debug(msg: str): print(f"{_tag()} {_gray('DEBUG')}: {msg}") -def print_command_output(msg: str): +def print_command_output(command_output: str): """ - Prints command output without a DECMAN tag if debug messages are enabled. + Prints command output prefixed with a DECMAN tag. """ - if config.debug_output: - print(msg) + for line in command_output.strip().split("\n"): + print_continuation(line.strip()) # ───────────────────────────── diff --git a/src/decman/plugins/aur/__init__.py b/src/decman/plugins/aur/__init__.py index c05c141..537d01f 100644 --- a/src/decman/plugins/aur/__init__.py +++ b/src/decman/plugins/aur/__init__.py @@ -231,6 +231,7 @@ class AUR(plugins.Plugin): except errors.CommandFailedError as error: output.print_error("Running a AUR command failed.") output.print_error(str(error)) + output.print_command_output(error.output) output.print_traceback() return False diff --git a/src/decman/plugins/flatpak.py b/src/decman/plugins/flatpak.py index 08690f1..cf1a757 100644 --- a/src/decman/plugins/flatpak.py +++ b/src/decman/plugins/flatpak.py @@ -93,6 +93,7 @@ class Flatpak(plugins.Plugin): except errors.CommandFailedError as error: output.print_error("Running a flatpak command failed.") output.print_error(str(error)) + output.print_command_output(error.output) output.print_traceback() return False return True diff --git a/src/decman/plugins/pacman.py b/src/decman/plugins/pacman.py index 3cf4d03..33302d2 100644 --- a/src/decman/plugins/pacman.py +++ b/src/decman/plugins/pacman.py @@ -111,6 +111,7 @@ class Pacman(plugins.Plugin): except errors.CommandFailedError as error: output.print_error("Running a pacman command failed.") output.print_error(str(error)) + output.print_command_output(error.output) output.print_traceback() return False return True diff --git a/src/decman/plugins/systemd.py b/src/decman/plugins/systemd.py index b7d8971..349b35f 100644 --- a/src/decman/plugins/systemd.py +++ b/src/decman/plugins/systemd.py @@ -179,6 +179,7 @@ class Systemd(plugins.Plugin): except errors.CommandFailedError as error: output.print_error("Running a systemd command failed.") output.print_error(str(error)) + output.print_command_output(error.output) output.print_traceback() return False return True diff --git a/tests/test_decman_plugins_pacman.py b/tests/test_decman_plugins_pacman.py index 7fe9a9c..ca03562 100644 --- a/tests/test_decman_plugins_pacman.py +++ b/tests/test_decman_plugins_pacman.py @@ -191,14 +191,18 @@ def test_apply_returns_false_on_command_failure(monkeypatch: pytest.MonkeyPatch) def fake_print_traceback() -> None: traceback_called.append(True) + def fake_print_continuation(msg: str) -> None: + continuations.append(msg) + monkeypatch.setattr(pacman_plugin.output, "print_error", fake_print_error) monkeypatch.setattr(pacman_plugin.output, "print_traceback", fake_print_traceback) + monkeypatch.setattr(pacman_plugin.output, "print_continuation", fake_print_continuation) ok = pacman.apply(store, dry_run=False) assert ok is False assert any("pacman command failed" in msg for msg in errors_logged) - assert any("boom" in msg for msg in errors_logged) + assert any("boom" in msg for msg in continuations) assert traceback_called # at least once