Skip to content
This repository was archived by the owner on Sep 22, 2023. It is now read-only.

Commit d5afaf9

Browse files
nokchalatteyoungjun0627
authored andcommitted
feat: Rich formatting (#174)
* Use Rich to pretty-format the announcements in CLI
1 parent 8ccf1ce commit d5afaf9

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

changes/174.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Utilize Rich as a formatting library for server announcements

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
'multidict>=5.1.0',
2020
'python-dateutil>=2.8.2',
2121
'PyYAML~=5.4.1',
22+
'rich~=10.5.0',
2223
'tabulate>=0.8.9',
2324
'tqdm>=4.61',
2425
'typing-extensions>=3.10.0',

src/ai/backend/client/cli/announcement.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
import appdirs
77

8-
from .pretty import print_info
9-
8+
from rich import print as rprint
109

1110
_printed_announcement = False
1211

@@ -27,10 +26,10 @@ def announce(msg: str, only_once: bool = True) -> None:
2726
msg_hash = hasher.hexdigest()
2827

2928
if not (last_state['hash'] == msg_hash and last_state['dismissed']):
30-
print_info("The server has an announcement!", file=sys.stderr)
31-
print('----------', file=sys.stderr)
32-
print(msg, file=sys.stderr)
33-
print('----------', file=sys.stderr)
29+
rprint('[bold cyan]The server has an announcement![/]', file=sys.stderr)
30+
rprint('[bold cyan]----------[/]', file=sys.stderr)
31+
rprint(f'[bold]{msg}[/]', file=sys.stderr)
32+
rprint('[bold cyan]----------[/]', file=sys.stderr)
3433
_printed_announcement = True
3534

3635
last_state['hash'] = msg_hash

0 commit comments

Comments
 (0)