mirror of
https://github.com/chatmail/relay.git
synced 2026-05-16 12:08:57 +00:00
refactor(cmdeploy): add Out class with --verbose, section timing, and coloured shell output
Move the Out output-printer class to cmdeploy/util.py so it is shared across CLI modules. All print/shell calls in lxc/cli.py, lxc/incus.py, and dns.py now route through Out instead of bare print(). Key additions: - Out.section() / Out.section_line(): coloured section headers scaled to the current terminal width (or $_CMDEPLOY_WIDTH for sub-processes). - Out.shell(): merges stdout/stderr, prefixes each output line, and prints a red error line with the exit code on failure. - Out.new_prefixed_out(): indented sub-printer that shares section_timings. - 'cmdeploy -v / -vv' exposes the verbosity levels. - shell(), collapse(), get_git_hash() and get_version_string() helpers. - Tests for Out added to test_util.py. Also update chatmaild MockOut fixture to match the new Out API.
This commit is contained in:
@@ -85,13 +85,13 @@ def mockout():
|
||||
captured_green = []
|
||||
captured_plain = []
|
||||
|
||||
def red(self, msg):
|
||||
def red(self, msg, **kw):
|
||||
self.captured_red.append(msg)
|
||||
|
||||
def green(self, msg):
|
||||
def green(self, msg, **kw):
|
||||
self.captured_green.append(msg)
|
||||
|
||||
def __call__(self, msg):
|
||||
def print(self, msg="", **kw):
|
||||
self.captured_plain.append(msg)
|
||||
|
||||
return MockOut()
|
||||
|
||||
Reference in New Issue
Block a user