cli: rich initial integration
This commit is contained in:
parent
ab7a7832c2
commit
bd2db73ee5
2 changed files with 20 additions and 0 deletions
|
|
@ -52,6 +52,7 @@ from libervia.frontends.bridge.bridge_frontend import BridgeException
|
|||
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 @@ class LiberviaCli:
|
|||
@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 @@ class LiberviaCli:
|
|||
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 @@ class CommandBase:
|
|||
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)
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
from libervia.frontends.quick_frontend import constants
|
||||
from libervia.backend.tools.common.ansi import ANSI as A
|
||||
from rich.theme import Theme
|
||||
|
||||
|
||||
class Const(constants.Const):
|
||||
|
|
@ -83,3 +84,12 @@ class Const(constants.Const):
|
|||
# Files
|
||||
A_DIRECTORY = A.BOLD + A.FG_CYAN
|
||||
A_FILE = A.FG_WHITE
|
||||
|
||||
# rich
|
||||
THEME_DEFAULT = Theme({
|
||||
"priority_low": "green",
|
||||
"priority_medium": "yellow",
|
||||
"priority_high": "bold magenta",
|
||||
"priority_urgent": "bold red",
|
||||
"notif_title": "bold",
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue