added a clear buffer method for Cli

This commit is contained in:
Natan Keddem
2023-11-04 00:00:51 -04:00
parent 78fbdf5007
commit d8e500da97
+6 -2
View File
@@ -118,8 +118,7 @@ class Cli:
try:
process = await asyncio.create_subprocess_shell(command, stdout=PIPE, stderr=PIPE)
if process is not None and process.stdout is not None and process.stderr is not None:
self.stdout.clear()
self.stderr.clear()
self.clear_buffers()
self._terminate.clear()
now = datetime.now().strftime("%Y/%m/%d %H:%M:%S")
self.prefix_line = f"<{now}> {command}\n"
@@ -136,6 +135,11 @@ class Cli:
self._busy = False
return Result(command=command, stdout_lines=self.stdout.copy(), stderr_lines=self.stderr.copy(), terminated=False)
def clear_buffers(self):
self.prefix_line = ""
self.stdout.clear()
self.stderr.clear()
def register_stdout_terminal(self, terminal: Terminal) -> None:
if terminal not in self._stdout_terminals:
terminal.call_terminal_method("write", self.prefix_line)