Skip to content

Commit

Permalink
Merge pull request #5636 from gibfahn/styles_const
Browse files Browse the repository at this point in the history
refactor(styles): make styles example use a const
  • Loading branch information
epage authored Aug 8, 2024
2 parents ecb4dca + 6f215ee commit 6fb49d0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion clap_builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ clap_lex = { path = "../clap_lex", version = "0.7.0" }
unicase = { version = "2.6.0", optional = true }
strsim = { version = "0.11.0", optional = true }
anstream = { version = "0.6.7", optional = true }
anstyle = "1.0.0"
anstyle = "1.0.8"
terminal_size = { version = "0.3.0", optional = true }
backtrace = { version = "0.3.73", optional = true }
unicode-width = { version = "0.1.9", optional = true }
Expand Down
10 changes: 5 additions & 5 deletions clap_builder/src/builder/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1199,13 +1199,13 @@ impl Command {
/// ```no_run
/// # use clap_builder as clap;
/// # use clap::{Command, ColorChoice, builder::styling};
/// let styles = styling::Styles::styled()
/// .header(styling::AnsiColor::Green.on_default() | styling::Effects::BOLD)
/// .usage(styling::AnsiColor::Green.on_default() | styling::Effects::BOLD)
/// .literal(styling::AnsiColor::Blue.on_default() | styling::Effects::BOLD)
/// const STYLES: styling::Styles = styling::Styles::styled()
/// .header(styling::AnsiColor::Green.on_default().bold())
/// .usage(styling::AnsiColor::Green.on_default().bold())
/// .literal(styling::AnsiColor::Blue.on_default().bold())
/// .placeholder(styling::AnsiColor::Cyan.on_default());
/// Command::new("myprog")
/// .styles(styles)
/// .styles(STYLES)
/// .get_matches();
/// ```
#[cfg(feature = "color")]
Expand Down
10 changes: 5 additions & 5 deletions src/bin/stdio-fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ fn main() {
#[cfg(feature = "color")]
{
use clap::builder::styling;
let styles = styling::Styles::styled()
.header(styling::AnsiColor::Green.on_default() | styling::Effects::BOLD)
.usage(styling::AnsiColor::Green.on_default() | styling::Effects::BOLD)
.literal(styling::AnsiColor::Blue.on_default() | styling::Effects::BOLD)
const STYLES: styling::Styles = styling::Styles::styled()
.header(styling::AnsiColor::Green.on_default().bold())
.usage(styling::AnsiColor::Green.on_default().bold())
.literal(styling::AnsiColor::Blue.on_default().bold())
.placeholder(styling::AnsiColor::Cyan.on_default());
cmd = cmd.styles(styles);
cmd = cmd.styles(STYLES);
}
cmd.get_matches();
}

0 comments on commit 6fb49d0

Please sign in to comment.