Skip to content

Commit 95a5c97

Browse files
committed
refactor(cli): colours alarm priority
1 parent 9c21258 commit 95a5c97

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

gallagher/cli/const.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
""" Constants in use for the CLI
2+
3+
This package contains definitions such as colours or output
4+
messages that are shared across various CLI endpoints.
5+
"""
6+
7+
# Define colors for each severity level (0-9)
8+
# See: https://rich.readthedocs.io/en/stable/appendix/colors.html
9+
SEVERITY_COLOURS = [
10+
"grey", # 0 - least severe
11+
"chartreuse1",
12+
"gold1",
13+
"yellow",
14+
"orange1",
15+
"deep_pink1",
16+
"deep_pink2",
17+
"deep_pink3",
18+
"red1",
19+
"red3", # 9 - most severe
20+
]

gallagher/dto/summary/alarm.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ class AlarmSummary(
5959
force_process: OptionalHrefMixin = None
6060

6161
def __rich_repr__(self):
62+
from gallagher.cli.const import SEVERITY_COLOURS
6263
return (
6364
self.id,
64-
f"{self.priority}",
65+
f"[{SEVERITY_COLOURS[self.priority]}]{self.priority}",
6566
self.time.strftime('%c'),
66-
self.type,
67+
f"[{SEVERITY_COLOURS[self.priority]}]{self.type}",
6768
)
6869

6970
def __str__(self):

0 commit comments

Comments
 (0)