Mercurial > libervia-backend
diff libervia/cli/base.py @ 4129:51744ad00a42
cli: `rich` initial integration
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 18 Oct 2023 15:30:07 +0200 |
parents | 47401850dec6 |
children | 33fd658d9d00 |
line wrap: on
line diff
--- a/libervia/cli/base.py Mon Oct 16 17:37:11 2023 +0200 +++ b/libervia/cli/base.py Wed Oct 18 15:30:07 2023 +0200 @@ -52,6 +52,7 @@ from libervia.frontends.tools import misc import xml.etree.ElementTree as ET # FIXME: used temporarily to manage XMLUI from collections import OrderedDict +from rich import console ## bridge handling # we get bridge name from conf and initialise the right class accordingly @@ -106,6 +107,7 @@ @attribute progress_failure(callable): method to call when progress failed by default display a message """ + self.console = console.Console(theme=C.THEME_DEFAULT) self.sat_conf = main_config self.set_color_theme() bridge_module = dynamic_import.bridge(bridge_name, 'libervia.frontends.bridge') @@ -734,6 +736,7 @@ def run(cls): cls()._run() + def _read_stdin(self, stdin_fut): """Callback called by ainput to read stdin""" line = sys.stdin.readline() @@ -1122,6 +1125,13 @@ def progress_id(self): return self.host.progress_id + @property + def console(self): + return self.host.console + + def print(self, *args, **kwargs): + self.host.console.print(*args, **kwargs) + async def set_progress_id(self, progress_id): return await self.host.set_progress_id(progress_id)