Skip to content

Commit

Permalink
cli: bold text in output
Browse files Browse the repository at this point in the history
  • Loading branch information
abhidg committed Sep 17, 2024
1 parent 6c88070 commit 888b817
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/olm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
from .report import make_report
from .lint import lint
from .outbreaks import OUTBREAKS
from .util import msg_ok, msg_fail
from .util import msg_ok, msg_fail, bold_brackets

USAGE = """olm: Office for Linelist Management
USAGE = """[olm]: [O]ffice for [L]inelist [M]anagement
olm is a tool to operate on linelists provided from Global.health (G.h).
[olm] is a tool to operate on linelists provided from Global.health (G.h).
Linelists are epidemiological datasets with information about a disease
outbreak organised into one row per case. Currently it supports
generating briefing reports, fetching linelists and checking linelists
against a provided schema.
olm is organised into subcommands:
list lists G.h outbreaks that olm supports
get saves linelist data to disk
report generates briefing report for an outbreak
lint lints (checks) an outbreak linelist for errors
[get] saves linelist data to disk
[list] lists G.h outbreaks that olm supports
[lint] lints (checks) an outbreak linelist for errors
[report] generates briefing report for an outbreak
"""


Expand Down Expand Up @@ -72,7 +72,10 @@ def main():
+ ", ".join(OUTBREAKS)
+ "\033[0m"
)
bold_outbreak = f"\033[1m{args.outbreak}\033[0m"
try:
bold_outbreak = f"\033[1m{args.outbreak}\033[0m"
except AttributeError:
bold_outbreak = None

match args.command:
case "list":
Expand Down Expand Up @@ -110,7 +113,7 @@ def main():
if args.open and (Path(args.outbreak + ".html")).exists():
webbrowser.open("file://" + str(Path.cwd() / (args.outbreak + ".html")))
case None:
print(USAGE)
print(bold_brackets(USAGE))


if __name__ == "__main__":
Expand Down
5 changes: 5 additions & 0 deletions src/olm/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ def rename_table(df: pd.DataFrame) -> pd.DataFrame:
return rename_table


def bold_brackets(s: str) -> str:
"""Given a text with brackets such as [this], renders it in bold font"""
return s.replace("[", "\033[1m").replace("]", "\033[0m")


def sort_values(
by: list[str], ascending: bool
) -> Callable[[pd.DataFrame], pd.DataFrame]:
Expand Down

0 comments on commit 888b817

Please sign in to comment.