Skip to content

Commit 6b2e024

Browse files
authored
Add color and wrapping to cli help text (#3849)
1 parent 5736ab6 commit 6b2e024

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

Cargo.lock

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sqlx-cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ sqlx = { workspace = true, default-features = false, features = [
3333
"any",
3434
] }
3535
futures = "0.3.19"
36-
clap = { version = "4.3.10", features = ["derive", "env"] }
36+
clap = { version = "4.3.10", features = ["derive", "env", "wrap_help"] }
3737
clap_complete = { version = "4.3.1", optional = true }
3838
chrono = { version = "0.4.19", default-features = false, features = ["clock"] }
3939
anyhow = "1.0.52"

sqlx-cli/src/opt.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
use std::ops::{Deref, Not};
22

3-
use clap::{Args, Parser};
3+
use clap::{
4+
builder::{styling::AnsiColor, Styles},
5+
Args, Parser,
6+
};
47
#[cfg(feature = "completions")]
58
use clap_complete::Shell;
69

10+
const HELP_STYLES: Styles = Styles::styled()
11+
.header(AnsiColor::Blue.on_default().bold())
12+
.usage(AnsiColor::Blue.on_default().bold())
13+
.literal(AnsiColor::White.on_default())
14+
.placeholder(AnsiColor::Green.on_default());
15+
716
#[derive(Parser, Debug)]
8-
#[clap(version, about, author)]
17+
#[clap(version, about, author, styles = HELP_STYLES)]
918
pub struct Opt {
1019
// https://github.com/launchbadge/sqlx/pull/3724 placed this here,
1120
// but the intuitive place would be in the arguments for each subcommand.

0 commit comments

Comments
 (0)