Skip to content

Commit 31c421c

Browse files
authored
Merge pull request #1651 from volta-cli/restore-color
Add colors back to help output
2 parents eacff22 + 168ef6e commit 31c421c

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ serde_json = "1.0.111"
2727
lazy_static = "1.3.0"
2828
log = { version = "0.4", features = ["std"] }
2929
node-semver = "2"
30-
clap = { version = "4.4.16", features = ["derive"] }
30+
clap = { version = "4.4.16", features = ["color", "derive", "wrap_help"] }
3131
clap_complete = "4.4.6"
3232
cfg-if = "1.0"
3333
mockito = { version = "0.31.1", optional = true }

src/cli.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use clap::Parser;
1+
use clap::{builder::styling, ColorChoice, Parser};
22

33
use crate::command::{self, Command};
44
use volta_core::error::{ExitCode, Fallible};
@@ -12,8 +12,9 @@ use volta_core::session::Session;
1212
1313
To install a tool in your toolchain, use `volta install`.
1414
To pin your project's runtime or package manager, use `volta pin`.",
15-
color = clap::ColorChoice::Auto,
15+
color = ColorChoice::Auto,
1616
disable_version_flag = true,
17+
styles = styles()
1718
)]
1819
pub(crate) struct Volta {
1920
#[command(subcommand)]
@@ -131,3 +132,19 @@ impl Subcommand {
131132
}
132133
}
133134
}
135+
136+
fn styles() -> styling::Styles {
137+
styling::Styles::plain()
138+
.header(
139+
styling::AnsiColor::Yellow.on_default()
140+
| styling::Effects::BOLD
141+
| styling::Effects::ITALIC,
142+
)
143+
.usage(
144+
styling::AnsiColor::Yellow.on_default()
145+
| styling::Effects::BOLD
146+
| styling::Effects::ITALIC,
147+
)
148+
.literal(styling::AnsiColor::Green.on_default() | styling::Effects::BOLD)
149+
.placeholder(styling::AnsiColor::BrightBlue.on_default())
150+
}

0 commit comments

Comments
 (0)