Skip to content

Commit

Permalink
feat: add color for clap (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
Decodetalkers authored Oct 17, 2024
1 parent e534c87 commit 7698b08
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,4 @@ tracing = { workspace = true }
snmalloc-rs = { version = "0.3", default-features = false, features = [
"build_cc",
], optional = true }
anstyle = "1.0.8"
39 changes: 39 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,47 @@ use human_panic::{metadata, setup_panic};

mod run;

pub const fn get_styles() -> clap::builder::Styles {
clap::builder::Styles::styled()
.usage(
anstyle::Style::new()
.bold()
.underline()
.fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::BrightCyan))),
)
.header(
anstyle::Style::new()
.bold()
.underline()
.fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::BrightCyan))),
)
.literal(
anstyle::Style::new().fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Magenta))),
)
.invalid(
anstyle::Style::new()
.bold()
.fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Red))),
)
.error(
anstyle::Style::new()
.bold()
.fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Red))),
)
.valid(
anstyle::Style::new()
.bold()
.underline()
.fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Magenta))),
)
.placeholder(
anstyle::Style::new().fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::White))),
)
}

#[derive(Debug, Parser)]
#[command(
styles = get_styles(),
name = "hatsu",
version = hatsu_utils::VERSION,
about,
Expand Down

0 comments on commit 7698b08

Please sign in to comment.