Skip to content

Commit 6fb49d0

Browse files
authored
Merge pull request #5636 from gibfahn/styles_const
refactor(styles): make styles example use a const
2 parents ecb4dca + 6f215ee commit 6fb49d0

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clap_builder/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ clap_lex = { path = "../clap_lex", version = "0.7.0" }
6363
unicase = { version = "2.6.0", optional = true }
6464
strsim = { version = "0.11.0", optional = true }
6565
anstream = { version = "0.6.7", optional = true }
66-
anstyle = "1.0.0"
66+
anstyle = "1.0.8"
6767
terminal_size = { version = "0.3.0", optional = true }
6868
backtrace = { version = "0.3.73", optional = true }
6969
unicode-width = { version = "0.1.9", optional = true }

clap_builder/src/builder/command.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,13 +1199,13 @@ impl Command {
11991199
/// ```no_run
12001200
/// # use clap_builder as clap;
12011201
/// # use clap::{Command, ColorChoice, builder::styling};
1202-
/// let styles = styling::Styles::styled()
1203-
/// .header(styling::AnsiColor::Green.on_default() | styling::Effects::BOLD)
1204-
/// .usage(styling::AnsiColor::Green.on_default() | styling::Effects::BOLD)
1205-
/// .literal(styling::AnsiColor::Blue.on_default() | styling::Effects::BOLD)
1202+
/// const STYLES: styling::Styles = styling::Styles::styled()
1203+
/// .header(styling::AnsiColor::Green.on_default().bold())
1204+
/// .usage(styling::AnsiColor::Green.on_default().bold())
1205+
/// .literal(styling::AnsiColor::Blue.on_default().bold())
12061206
/// .placeholder(styling::AnsiColor::Cyan.on_default());
12071207
/// Command::new("myprog")
1208-
/// .styles(styles)
1208+
/// .styles(STYLES)
12091209
/// .get_matches();
12101210
/// ```
12111211
#[cfg(feature = "color")]

src/bin/stdio-fixture.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ fn main() {
1515
#[cfg(feature = "color")]
1616
{
1717
use clap::builder::styling;
18-
let styles = styling::Styles::styled()
19-
.header(styling::AnsiColor::Green.on_default() | styling::Effects::BOLD)
20-
.usage(styling::AnsiColor::Green.on_default() | styling::Effects::BOLD)
21-
.literal(styling::AnsiColor::Blue.on_default() | styling::Effects::BOLD)
18+
const STYLES: styling::Styles = styling::Styles::styled()
19+
.header(styling::AnsiColor::Green.on_default().bold())
20+
.usage(styling::AnsiColor::Green.on_default().bold())
21+
.literal(styling::AnsiColor::Blue.on_default().bold())
2222
.placeholder(styling::AnsiColor::Cyan.on_default());
23-
cmd = cmd.styles(styles);
23+
cmd = cmd.styles(STYLES);
2424
}
2525
cmd.get_matches();
2626
}

0 commit comments

Comments
 (0)