pretty print help options using tabulate

This commit is contained in:
mungai-njoroge
2023-08-29 20:40:06 +03:00
parent 13475b0630
commit 8b25a9265f
4 changed files with 65 additions and 16 deletions
+26 -15
View File
@@ -1,23 +1,34 @@
from app.settings import ALLARGS
from tabulate import tabulate
args = ALLARGS
help_args_list = [
["--help", "-h", "Show this help message"],
["--version", "-v", "Show the app version"],
["--host", "", "Set the host"],
["--port", "", "Set the port"],
["--config", "", "Set the config path"],
["--no-periodic-scan", "-nps", "Disable periodic scan"],
[
"--scan-interval",
"-psi",
"Set the periodic scan interval in seconds. Default is 300 seconds (5 minutes)",
],
[
"--build",
"",
"Build the application (in development)",
],
]
HELP_MESSAGE = f"""
Swing Music is a beautiful, self-hosted music player for your
local audio files. Like a cooler Spotify ... but bring your own music.
Usage: swingmusic [options]
Swing Music is a beautiful, self-hosted music player for your local audio files. Like a cooler Spotify ... but bring your own music.
Options:
{', '.join(args.help)}: Show this help message
{', '.join(args.version)}: Show the app version
{args.host}: Set the host
{args.port}: Set the port
{args.config}: Set the config path
{', '.join(args.no_periodic_scan)}: Disable periodic scan
{', '.join(args.periodic_scan_interval)}: Set the periodic scan interval in seconds. Default is 300 seconds (5
minutes)
{args.build}: Build the application (in development)
{tabulate(help_args_list, headers=["Option", "Short", "Description"], tablefmt="rounded_grid", maxcolwidths=[None, None, 44])}
"""
"80s, 90s, the noughties and today"