From 5a556dd8f906fb3b21bca9ed9b4945efd4011f7c Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Sun, 14 Jan 2024 21:22:52 +0100 Subject: [PATCH] enh: Add colors to help texts --- src/commands.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/commands.rs b/src/commands.rs index 6ff90ec9d..f5a0de4ed 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -45,6 +45,10 @@ use abscissa_core::{ FrameworkErrorKind, Runnable, Shutdown, }; use anyhow::{anyhow, Result}; +use clap::builder::{ + styling::{AnsiColor, Effects}, + Styles, +}; use dialoguer::Password; use log::{log, Level}; use rustic_core::{OpenStatus, Repository}; @@ -127,9 +131,17 @@ enum RusticCmd { Tag(TagCmd), } +fn styles() -> Styles { + Styles::styled() + .header(AnsiColor::Red.on_default() | Effects::BOLD) + .usage(AnsiColor::Red.on_default() | Effects::BOLD) + .literal(AnsiColor::Blue.on_default() | Effects::BOLD) + .placeholder(AnsiColor::Green.on_default()) +} + /// Entry point for the application. It needs to be a struct to allow using subcommands! #[derive(clap::Parser, Command, Debug)] -#[command(author, about, name="rustic", version = option_env!("PROJECT_VERSION").unwrap_or(env!("CARGO_PKG_VERSION")))] +#[command(author, about, name="rustic", styles=styles(), version = option_env!("PROJECT_VERSION").unwrap_or(env!("CARGO_PKG_VERSION")))] pub struct EntryPoint { #[command(flatten)] pub config: RusticConfig,