replace terminaltables with rich tables.

allow rich to handle all console output.

util.check_mark is now used to pass back colourless check/cross marks if NO_COLOR is set or --style/SLOBS_STYLE was not set.
This commit is contained in:
2025-06-22 02:52:27 +01:00
parent 6bcdd8391c
commit c02ffac403
10 changed files with 209 additions and 118 deletions

View File

@@ -4,6 +4,8 @@ import json
import asyncclick as click
from . import console
class SlobsCliError(click.ClickException):
"""Base class for all Slobs CLI errors."""
@@ -14,8 +16,8 @@ class SlobsCliError(click.ClickException):
self.exit_code = 1
def show(self):
"""Display the error message in red."""
click.secho(f'Error: {self.message}', fg='red', err=True)
"""Display the error message in red and write to stderr."""
console.err.print(f'Error: {self.message}')
class SlobsCliProtocolError(SlobsCliError):
@@ -36,10 +38,8 @@ class SlobsCliProtocolError(SlobsCliError):
"""Display the protocol error message in red."""
match self.protocol_code:
case -32600:
click.secho(
'Oops! Looks like we hit a rate limit for this command. Please try again later.',
fg='red',
err=True,
console.err.print(
'Oops! Looks like we hit a rate limit for this command. Please try again later.'
)
case _:
# Fall back to the base error display for unknown protocol codes