From 4c2e9e9a86ec146a53a51a4ae3b6792cda6dcb09 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 28 Nov 2024 22:06:38 +0100 Subject: [PATCH] fix: separation between run and print function --- src/rougail/output_console/__init__.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/rougail/output_console/__init__.py b/src/rougail/output_console/__init__.py index 810dbe1..235aa04 100644 --- a/src/rougail/output_console/__init__.py +++ b/src/rougail/output_console/__init__.py @@ -119,9 +119,15 @@ class RougailOutputConsole: self.end() return True - def run(self) -> None: + def run(self) -> str: + with self.console.capture() as capture: + self.print() + return capture.get() + + def print(self) -> None: self.exporter() - return self.print() + for out in self.out: + self.console.print(out) def parse_options( self, @@ -216,10 +222,6 @@ class RougailOutputConsole: def end(self): self.out.append(self.output.tree) - def print(self): - for out in self.out: - self.console.print(out) - class OutputFamily: def __init__(