diff --git a/crates/ruff/src/args.rs b/crates/ruff/src/args.rs index eb4bcd0a92..e1c114a66e 100644 --- a/crates/ruff/src/args.rs +++ b/crates/ruff/src/args.rs @@ -7,6 +7,8 @@ use std::sync::Arc; use crate::commands::completions::config::{OptionString, OptionStringParser}; use anyhow::bail; +use clap::builder::Styles; +use clap::builder::styling::{AnsiColor, Effects}; use clap::builder::{TypedValueParser, ValueParserFactory}; use clap::{Parser, Subcommand, command}; use colored::Colorize; @@ -78,6 +80,13 @@ impl GlobalConfigArgs { } } +// Configures Clap v3-style help menu colors +const STYLES: Styles = Styles::styled() + .header(AnsiColor::Green.on_default().effects(Effects::BOLD)) + .usage(AnsiColor::Green.on_default().effects(Effects::BOLD)) + .literal(AnsiColor::Cyan.on_default().effects(Effects::BOLD)) + .placeholder(AnsiColor::Cyan.on_default()); + #[derive(Debug, Parser)] #[command( author, @@ -86,6 +95,7 @@ impl GlobalConfigArgs { after_help = "For help with a specific command, see: `ruff help `." )] #[command(version)] +#[command(styles = STYLES)] pub struct Args { #[command(subcommand)] pub(crate) command: Command, diff --git a/crates/ty/src/args.rs b/crates/ty/src/args.rs index f6a52a3c8c..ac334f37bf 100644 --- a/crates/ty/src/args.rs +++ b/crates/ty/src/args.rs @@ -1,5 +1,7 @@ use crate::logging::Verbosity; use crate::python_version::PythonVersion; +use clap::builder::Styles; +use clap::builder::styling::{AnsiColor, Effects}; use clap::error::ErrorKind; use clap::{ArgAction, ArgMatches, Error, Parser}; use ruff_db::system::SystemPathBuf; @@ -8,9 +10,17 @@ use ty_project::metadata::options::{EnvironmentOptions, Options, SrcOptions, Ter use ty_project::metadata::value::{RangedValue, RelativeGlobPattern, RelativePathBuf, ValueSource}; use ty_python_semantic::lint; +// Configures Clap v3-style help menu colors +const STYLES: Styles = Styles::styled() + .header(AnsiColor::Green.on_default().effects(Effects::BOLD)) + .usage(AnsiColor::Green.on_default().effects(Effects::BOLD)) + .literal(AnsiColor::Cyan.on_default().effects(Effects::BOLD)) + .placeholder(AnsiColor::Cyan.on_default()); + #[derive(Debug, Parser)] #[command(author, name = "ty", about = "An extremely fast Python type checker.")] #[command(long_version = crate::version::version())] +#[command(styles = STYLES)] pub struct Cli { #[command(subcommand)] pub(crate) command: Command,