Skip to content

Commit

Permalink
added colors to the help command
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Gadorek committed Jul 16, 2024
1 parent f7bbbb9 commit 3aa606c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
[dependencies]
tokio = {version = "1.37.0", features=["full"]}
idf-im-lib = { git = "https://github.com/espressif/idf-im-lib.git", branch="master" }
clap = {version = "4.5", features = ["cargo", "derive"]}
clap = {version = "4.5", features = ["cargo", "derive", "color"]}
crossterm = "0.27.0"
dialoguer = { git = "https://github.com/Hahihula/dialoguer.git", branch = "folder-select", features = ["folder-select"] }
byte-unit = "5.1.4"
Expand Down
26 changes: 23 additions & 3 deletions src/cli_args/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use clap::Parser;
use clap::{arg, ValueEnum};
use clap::builder::styling::{AnsiColor, Color, Style, Styles};
use clap::CommandFactory;
use clap::{arg, command, value_parser, ColorChoice, Parser, ValueEnum};
use config::{Config, ConfigError, File};
use log::{debug, error, info};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -28,12 +29,31 @@ pub struct Settings {
pub idf_mirror: Option<String>,
}

fn custom_styles() -> Styles {
Styles::styled()
.header(
Style::new()
.bold()
.underline()
.fg_color(Some(Color::Ansi(AnsiColor::Yellow))),
)
.usage(
Style::new()
.bold()
.fg_color(Some(Color::Ansi(AnsiColor::Green))),
)
.literal(Style::new().fg_color(Some(Color::Ansi(AnsiColor::Magenta))))
.placeholder(Style::new().fg_color(Some(Color::Ansi(AnsiColor::Red))))
}

#[derive(Parser, Debug)]
#[command(
author,
version = VERSION,
about = "ESP-IDF Install Manager",
long_about = "All you need to manage your ESP-IDF installations"
long_about = "All you need to manage your ESP-IDF installations",
color = ColorChoice::Always,
styles = custom_styles()
)]
pub struct Cli {
#[arg(short, long, value_name = "FILE")]
Expand Down

0 comments on commit 3aa606c

Please sign in to comment.