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

Commit

Permalink
feat: Rich formatting (#174)
Browse files Browse the repository at this point in the history
* Use Rich to pretty-format the announcements in CLI
  • Loading branch information
nokchalatte committed Aug 31, 2021
1 parent c86d588 commit 32e53e2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions changes/174.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Utilize Rich as a formatting library for server announcements
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'multidict>=5.1.0',
'python-dateutil>=2.8.2',
'PyYAML~=5.4.1',
'rich~=10.5.0',
'tabulate>=0.8.9',
'tqdm>=4.61',
'typing-extensions>=3.10.0',
Expand Down
11 changes: 5 additions & 6 deletions src/ai/backend/client/cli/announcement.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

import appdirs

from .pretty import print_info

from rich import print as rprint

_printed_announcement = False

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

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

last_state['hash'] = msg_hash
Expand Down

0 comments on commit 32e53e2

Please sign in to comment.