diff options
-rw-r--r-- | fietsboek/scripts/fietsctl.py | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/fietsboek/scripts/fietsctl.py b/fietsboek/scripts/fietsctl.py index 913da69..4950f7e 100644 --- a/fietsboek/scripts/fietsctl.py +++ b/fietsboek/scripts/fietsctl.py @@ -15,6 +15,13 @@ from . import config_option EXIT_OKAY = 0 EXIT_FAILURE = 1 +FG_USER_NAME = "yellow" +FG_USER_EMAIL = "yellow" +FG_USER_TAG = "red" +FG_SIZE = "cyan" +FG_TRACK_TITLE = "green" +FG_TRACK_SIZE = "bright_red" + def human_bool(value: bool) -> str: """Formats a boolean for CLI output. @@ -142,7 +149,7 @@ def user_del( if user is None: click.echo("Error: No such user found.", err=True) ctx.exit(EXIT_FAILURE) - click.echo(user.name) + click.secho(user.name, fg=FG_USER_NAME) click.echo(user.email) if not force: if not click.confirm("Really delete this user?"): @@ -174,7 +181,10 @@ def cmd_user_list(config: str): "a" if user.is_admin else "-", "v" if user.is_verified else "-", ) - click.echo(f"{tag} {user.id} - {user.email} - {user.name}") + tag = click.style(tag, fg=FG_USER_TAG) + user_email = click.style(user.email, fg=FG_USER_EMAIL) + user_name = click.style(user.name, fg=FG_USER_NAME) + click.echo(f"{tag} {user.id} - {user_email} - {user_name}") @cmd_user.command("passwd") @@ -207,7 +217,9 @@ def cms_user_passwd( password = click.prompt("Password", hide_input=True, confirmation_prompt=True) user.set_password(password) - click.echo(f"Changed password of {user.name} ({user.email})") + user_name = click.style(user.name, fg=FG_USER_NAME) + user_email = click.style(user.email, fg=FG_USER_EMAIL) + click.echo(f"Changed password of {user_name} ({user_email})") @cmd_user.command("modify") @@ -244,7 +256,9 @@ def cms_user_modify( if verified is not None: user.is_verified = verified - click.echo(f"{user.name} - {user.email}") + user_name = click.style(user.name, fg=FG_USER_NAME) + user_email = click.style(user.email, fg=FG_USER_EMAIL) + click.echo(f"{user_name} - {user_email}") click.echo(f"Is admin: {human_bool(user.is_admin)}") click.echo(f"Is verified: {human_bool(user.is_verified)}") @@ -302,7 +316,7 @@ def cmd_user_hittekaart( user_manager.tilehunt_path().unlink(missing_ok=True) return - click.echo(f"Generating overlay maps for {user.name}...") + click.echo(f"Generating overlay maps for {click.style(user.name, fg=FG_USER_NAME)}...") for mode in modes: hittekaart.generate_for( @@ -336,12 +350,15 @@ def cmd_track_list(config: str): else: total_size += track_size size = util.human_size(track_size) - click.echo( - f"{track.id:>4} - {size:>10} - {track.owner.name} <{track.owner.email}>" - f" - {track.title}" - ) + size = click.style(f"{size:>10}", fg=FG_TRACK_SIZE) + owner_name = click.style(track.owner.name, fg=FG_USER_NAME) + owner_email = click.style(track.owner.email, fg=FG_USER_EMAIL) + track_title = click.style(track.title, fg=FG_TRACK_TITLE) + click.echo(f"{track.id:>4} - {size} - {owner_name} <{owner_email}> - {track_title}") click.echo("-" * 80) - click.echo(f"Total: {total_tracks} - {util.human_size(total_size)}") + click.echo( + f"Total: {total_tracks} - {click.style(util.human_size(total_size), fg=FG_TRACK_SIZE)}" + ) @cli.command("maintenance-mode") |