Skip to content

Commit 9010582

Browse files
committed
refactor: improve list-policies UI.
Signed-off-by: Demolus13 <[email protected]>
1 parent 94feadc commit 9010582

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/macaron/__main__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,13 @@ def verify_policy(verify_policy_args: argparse.Namespace) -> int:
230230
logger.error("Policy directory %s not found.", policy_dir)
231231
return os.EX_OSFILE
232232

233+
policies_with_desc = dict(sorted(policies_with_desc.items()))
233234
rich_handler = access_handler.get_handler()
234235
rich_handler.set_available_policies(policies_with_desc)
235236

236-
logger.info("Available policies are:\n\t%s", "\n\t".join(sorted(policies_with_desc)))
237+
logger.info(
238+
"Available policies are:\n%s", "\n".join(f"{name}\n{desc}\n" for name, desc in policies_with_desc.items())
239+
)
237240
return os.EX_OK
238241

239242
if verify_policy_args.file:

src/macaron/console.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,13 @@ def _make_reports_table(reports: dict) -> Table:
8080
def _make_policies_table(policies: dict[str, str]) -> Table:
8181
"""Build a two-column table of policy name and a short description."""
8282
table = Table(box=None)
83-
table.add_column("Policy", justify="left", style="bold")
83+
table.add_column("[blue]Policy[/]", justify="left", style="blue bold")
8484
table.add_column("Description", justify="left")
85-
for name, desc in policies.items():
85+
total_policies = len(policies)
86+
for i, (name, desc) in enumerate(policies.items()):
8687
table.add_row(name, desc)
88+
if i < total_policies - 1:
89+
table.add_row()
8790
return table
8891

8992

0 commit comments

Comments
 (0)