From e46379a7f383f87da14e658760eaae7ec6b34fc4 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 30 Aug 2023 15:55:50 -0500 Subject: [PATCH 1/2] fix(remove): Include 'cargo help' suggestion in -h --- src/bin/cargo/commands/remove.rs | 1 + tests/testsuite/cargo_remove/help/stdout.log | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/bin/cargo/commands/remove.rs b/src/bin/cargo/commands/remove.rs index e8f6ab98e..b353609cb 100644 --- a/src/bin/cargo/commands/remove.rs +++ b/src/bin/cargo/commands/remove.rs @@ -50,6 +50,7 @@ pub fn cli() -> clap::Command { ]) .arg_package("Package to remove from") .arg_manifest_path() + .after_help("Run `cargo help remove` for more detailed information.\n") } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/tests/testsuite/cargo_remove/help/stdout.log b/tests/testsuite/cargo_remove/help/stdout.log index 81a2d78b6..b8d16f0c2 100644 --- a/tests/testsuite/cargo_remove/help/stdout.log +++ b/tests/testsuite/cargo_remove/help/stdout.log @@ -27,3 +27,5 @@ Manifest Options: --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date --offline Run without accessing the network + +Run `cargo help remove` for more detailed information. From dbbc5dd6eba308f266fe67190cd04c27109dd736 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 28 Aug 2023 12:05:19 -0500 Subject: [PATCH 2/2] feat(help): Add styling to help output Traditionally, cargo has disabled clap's styled help output. My assumed reason is that cargo mixes custom help output with auto-generated and you couldn't previously make it all styled to match. Clap 4.2 allowed users to pass in strings styled using ANSI escape codes, allowing us to pass in styled text that matches clap, unblocking this. In clap 4.4.1, clap gained the ability for the user to override the style, allowing us to choose the styling as we wish. In this PR, I decided to use the new 4.4.1 feature to style clap's output to match the rest of cargo's output. Alternatively, we could use a more subdue style that clap uses by default. That subdued style was mostly chosen to be app theme neurtral (since we didn't have theming support yet) and there were problems with our style and no one stepped up to fix them (cargo has a style we can match to instead). I decided to *not* style `Arg::help` messages because - It might be distracting to have the descriptions lit up like a christmas tree - It is a lot more work The one exception I made was for `--list` since it is for a psuedo-command (`...`) and I wanted to intentionally draw attention to it. --- Cargo.lock | 22 +++++++ Cargo.toml | 2 + src/bin/cargo/cli.rs | 67 ++++++++++++--------- src/bin/cargo/commands/add.rs | 12 ++-- src/bin/cargo/commands/bench.rs | 4 +- src/bin/cargo/commands/build.rs | 4 +- src/bin/cargo/commands/check.rs | 4 +- src/bin/cargo/commands/clean.rs | 4 +- src/bin/cargo/commands/doc.rs | 4 +- src/bin/cargo/commands/fetch.rs | 4 +- src/bin/cargo/commands/fix.rs | 4 +- src/bin/cargo/commands/generate_lockfile.rs | 4 +- src/bin/cargo/commands/init.rs | 4 +- src/bin/cargo/commands/install.rs | 4 +- src/bin/cargo/commands/locate_project.rs | 4 +- src/bin/cargo/commands/login.rs | 4 +- src/bin/cargo/commands/logout.rs | 4 +- src/bin/cargo/commands/metadata.rs | 4 +- src/bin/cargo/commands/new.rs | 4 +- src/bin/cargo/commands/owner.rs | 4 +- src/bin/cargo/commands/package.rs | 4 +- src/bin/cargo/commands/pkgid.rs | 4 +- src/bin/cargo/commands/publish.rs | 4 +- src/bin/cargo/commands/read_manifest.rs | 8 +-- src/bin/cargo/commands/remove.rs | 4 +- src/bin/cargo/commands/report.rs | 4 +- src/bin/cargo/commands/run.rs | 4 +- src/bin/cargo/commands/rustc.rs | 4 +- src/bin/cargo/commands/rustdoc.rs | 4 +- src/bin/cargo/commands/search.rs | 4 +- src/bin/cargo/commands/test.rs | 8 +-- src/bin/cargo/commands/tree.rs | 4 +- src/bin/cargo/commands/uninstall.rs | 4 +- src/bin/cargo/commands/update.rs | 4 +- src/bin/cargo/commands/vendor.rs | 4 +- src/bin/cargo/commands/verify_project.rs | 4 +- src/bin/cargo/commands/version.rs | 4 +- src/bin/cargo/commands/yank.rs | 4 +- 38 files changed, 173 insertions(+), 74 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f72609c1b..94a1875eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,6 +270,7 @@ dependencies = [ "cargo-test-support", "cargo-util", "clap", + "color-print", "crates-io", "curl", "curl-sys", @@ -540,6 +541,27 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8191fa7302e03607ff0e237d4246cc043ff5b3cb9409d995172ba3bea16b807" +[[package]] +name = "color-print" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2a5e6504ed8648554968650feecea00557a3476bc040d0ffc33080e66b646d0" +dependencies = [ + "color-print-proc-macro", +] + +[[package]] +name = "color-print-proc-macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d51beaa537d73d2d1ff34ee70bc095f170420ab2ec5d687ecd3ec2b0d092514b" +dependencies = [ + "nom", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "colorchoice" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index b6edc38ac..d80e755dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,7 @@ cargo-test-support = { path = "crates/cargo-test-support" } cargo-util = { version = "0.2.6", path = "crates/cargo-util" } cargo_metadata = "0.17.0" clap = "4.4.2" +color-print = "0.3.4" core-foundation = { version = "0.9.3", features = ["mac_os_10_7_support"] } crates-io = { version = "0.39.0", path = "crates/crates-io" } criterion = { version = "0.5.1", features = ["html_reports"] } @@ -129,6 +130,7 @@ cargo-credential-libsecret.workspace = true cargo-credential-macos-keychain.workspace = true cargo-credential-wincred.workspace = true cargo-util.workspace = true +color-print.workspace = true clap = { workspace = true, features = ["wrap_help"] } crates-io.workspace = true curl = { workspace = true, features = ["http2"] } diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index d39dce754..dc0a34bfa 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -513,10 +513,23 @@ impl GlobalArgs { pub fn cli() -> Command { let usage = if is_rustup() { - "cargo [+toolchain] [OPTIONS] [COMMAND]\n cargo [+toolchain] [OPTIONS] -Zscript [ARGS]..." + color_print::cstr!("cargo [+toolchain] [OPTIONS] [COMMAND]\n cargo [+toolchain] [OPTIONS] -Zscript <> [ARGS]...") } else { - "cargo [OPTIONS] [COMMAND]\n cargo [OPTIONS] -Zscript [ARGS]..." + color_print::cstr!("cargo [OPTIONS] [COMMAND]\n cargo [OPTIONS] -Zscript <> [ARGS]...") }; + + let styles = { + use clap::builder::styling::*; + Styles::styled() + .header(AnsiColor::Green.on_default() | Effects::BOLD) + .usage(AnsiColor::Green.on_default() | Effects::BOLD) + .literal(AnsiColor::Cyan.on_default() | Effects::BOLD) + .placeholder(AnsiColor::Cyan.on_default()) + .error(AnsiColor::Red.on_default() | Effects::BOLD) + .valid(AnsiColor::Cyan.on_default() | Effects::BOLD) + .invalid(AnsiColor::Yellow.on_default() | Effects::BOLD) + }; + Command::new("cargo") // Subcommands all count their args' display order independently (from 0), // which makes their args interspersed with global args. This puts global args last. @@ -524,42 +537,40 @@ pub fn cli() -> Command { // We also want these to come before auto-generated `--help` .next_display_order(800) .allow_external_subcommands(true) - // Doesn't mix well with our list of common cargo commands. See clap-rs/clap#3108 for - // opening clap up to allow us to style our help template - .disable_colored_help(true) + .styles(styles) // Provide a custom help subcommand for calling into man pages .disable_help_subcommand(true) .override_usage(usage) - .help_template( + .help_template(color_print::cstr!( "\ Rust's package manager -Usage: {usage} +Usage: {usage} -Options: +Options: {options} -Commands: - build, b Compile the current package - check, c Analyze the current package and report errors, but don't build object files - clean Remove the target directory - doc, d Build this package's and its dependencies' documentation - new Create a new cargo package - init Create a new cargo package in an existing directory - add Add dependencies to a manifest file - remove Remove dependencies from a manifest file - run, r Run a binary or example of the local package - test, t Run the tests - bench Run the benchmarks - update Update dependencies listed in Cargo.lock - search Search registry for crates - publish Package and upload this package to the registry - install Install a Rust binary. Default location is $HOME/.cargo/bin - uninstall Uninstall a Rust binary - ... See all commands with --list +Commands: + build, b Compile the current package + check, c Analyze the current package and report errors, but don't build object files + clean Remove the target directory + doc, d Build this package's and its dependencies' documentation + new Create a new cargo package + init Create a new cargo package in an existing directory + add Add dependencies to a manifest file + remove Remove dependencies from a manifest file + run, r Run a binary or example of the local package + test, t Run the tests + bench Run the benchmarks + update Update dependencies listed in Cargo.lock + search Search registry for crates + publish Package and upload this package to the registry + install Install a Rust binary. Default location is $HOME/.cargo/bin + uninstall Uninstall a Rust binary + ... See all commands with --list -See 'cargo help ' for more information on a specific command.\n", - ) +See 'cargo help <>' for more information on a specific command.\n", + )) .arg(flag("version", "Print version info and exit").short('V')) .arg(flag("list", "List installed commands")) .arg( diff --git a/src/bin/cargo/commands/add.rs b/src/bin/cargo/commands/add.rs index 56df76268..344cd2af3 100644 --- a/src/bin/cargo/commands/add.rs +++ b/src/bin/cargo/commands/add.rs @@ -18,12 +18,12 @@ pub fn cli() -> Command { clap::Command::new("add") .about("Add dependencies to a Cargo.toml manifest file") .override_usage( - "\ - cargo add [OPTIONS] [@] ... - cargo add [OPTIONS] --path ... - cargo add [OPTIONS] --git ..." - ) - .after_help("Run `cargo help add` for more detailed information.\n") + color_print::cstr!("\ + cargo add [OPTIONS] <>[@<>] ... + cargo add [OPTIONS] --path <> ... + cargo add [OPTIONS] --git <> ..." + )) + .after_help(color_print::cstr!("Run `cargo help add` for more detailed information.\n")) .group(clap::ArgGroup::new("selected").multiple(true).required(true)) .args([ clap::Arg::new("crates") diff --git a/src/bin/cargo/commands/bench.rs b/src/bin/cargo/commands/bench.rs index 971dc9456..1a97d84a4 100644 --- a/src/bin/cargo/commands/bench.rs +++ b/src/bin/cargo/commands/bench.rs @@ -50,7 +50,9 @@ pub fn cli() -> Command { .arg_unit_graph() .arg_timings() .arg_manifest_path() - .after_help("Run `cargo help bench` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help bench` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/build.rs b/src/bin/cargo/commands/build.rs index 19076d328..7197cdbad 100644 --- a/src/bin/cargo/commands/build.rs +++ b/src/bin/cargo/commands/build.rs @@ -46,7 +46,9 @@ pub fn cli() -> Command { .arg_unit_graph() .arg_timings() .arg_manifest_path() - .after_help("Run `cargo help build` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help build` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/check.rs b/src/bin/cargo/commands/check.rs index 62df0c106..a54e84cdc 100644 --- a/src/bin/cargo/commands/check.rs +++ b/src/bin/cargo/commands/check.rs @@ -37,7 +37,9 @@ pub fn cli() -> Command { .arg_unit_graph() .arg_timings() .arg_manifest_path() - .after_help("Run `cargo help check` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help check` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/clean.rs b/src/bin/cargo/commands/clean.rs index c47e16702..8a5645e33 100644 --- a/src/bin/cargo/commands/clean.rs +++ b/src/bin/cargo/commands/clean.rs @@ -14,7 +14,9 @@ pub fn cli() -> Command { .arg_target_triple("Target triple to clean output for") .arg_target_dir() .arg_manifest_path() - .after_help("Run `cargo help clean` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help clean` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/doc.rs b/src/bin/cargo/commands/doc.rs index e209eb7db..43a6ee950 100644 --- a/src/bin/cargo/commands/doc.rs +++ b/src/bin/cargo/commands/doc.rs @@ -40,7 +40,9 @@ pub fn cli() -> Command { .arg_unit_graph() .arg_timings() .arg_manifest_path() - .after_help("Run `cargo help doc` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help doc` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/fetch.rs b/src/bin/cargo/commands/fetch.rs index ba9e8d82b..794dbf9b0 100644 --- a/src/bin/cargo/commands/fetch.rs +++ b/src/bin/cargo/commands/fetch.rs @@ -9,7 +9,9 @@ pub fn cli() -> Command { .arg_quiet() .arg_target_triple("Fetch dependencies for the target triple") .arg_manifest_path() - .after_help("Run `cargo help fetch` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help fetch` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/fix.rs b/src/bin/cargo/commands/fix.rs index 96afbbdcc..0ecf47450 100644 --- a/src/bin/cargo/commands/fix.rs +++ b/src/bin/cargo/commands/fix.rs @@ -54,7 +54,9 @@ pub fn cli() -> Command { .arg_target_dir() .arg_timings() .arg_manifest_path() - .after_help("Run `cargo help fix` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help fix` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/generate_lockfile.rs b/src/bin/cargo/commands/generate_lockfile.rs index 7d06aad59..4f1382ee5 100644 --- a/src/bin/cargo/commands/generate_lockfile.rs +++ b/src/bin/cargo/commands/generate_lockfile.rs @@ -7,7 +7,9 @@ pub fn cli() -> Command { .about("Generate the lockfile for a package") .arg_quiet() .arg_manifest_path() - .after_help("Run `cargo help generate-lockfile` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help generate-lockfile` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/init.rs b/src/bin/cargo/commands/init.rs index fdb3dc208..d699c2c49 100644 --- a/src/bin/cargo/commands/init.rs +++ b/src/bin/cargo/commands/init.rs @@ -9,7 +9,9 @@ pub fn cli() -> Command { .arg_new_opts() .arg(opt("registry", "Registry to use").value_name("REGISTRY")) .arg_quiet() - .after_help("Run `cargo help init` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help init` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/install.rs b/src/bin/cargo/commands/install.rs index b4937fa6f..e7907f449 100644 --- a/src/bin/cargo/commands/install.rs +++ b/src/bin/cargo/commands/install.rs @@ -87,7 +87,9 @@ pub fn cli() -> Command { .arg_target_triple("Build for the target triple") .arg_target_dir() .arg_timings() - .after_help("Run `cargo help install` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help install` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/locate_project.rs b/src/bin/cargo/commands/locate_project.rs index 69f015300..217bdcac9 100644 --- a/src/bin/cargo/commands/locate_project.rs +++ b/src/bin/cargo/commands/locate_project.rs @@ -16,7 +16,9 @@ pub fn cli() -> Command { ) .arg_quiet() .arg_manifest_path() - .after_help("Run `cargo help locate-project` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help locate-project` for more detailed information.\n" + )) } #[derive(Serialize)] diff --git a/src/bin/cargo/commands/login.rs b/src/bin/cargo/commands/login.rs index e51adaa1c..262e3d6b0 100644 --- a/src/bin/cargo/commands/login.rs +++ b/src/bin/cargo/commands/login.rs @@ -14,7 +14,9 @@ pub fn cli() -> Command { .last(true), ) .arg_quiet() - .after_help("Run `cargo help login` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help login` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/logout.rs b/src/bin/cargo/commands/logout.rs index 4320240c6..a4fae5bd6 100644 --- a/src/bin/cargo/commands/logout.rs +++ b/src/bin/cargo/commands/logout.rs @@ -6,7 +6,9 @@ pub fn cli() -> Command { .about("Remove an API token from the registry locally") .arg(opt("registry", "Registry to use").value_name("REGISTRY")) .arg_quiet() - .after_help("Run `cargo help logout` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help logout` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/metadata.rs b/src/bin/cargo/commands/metadata.rs index 54257dee3..09064de7d 100644 --- a/src/bin/cargo/commands/metadata.rs +++ b/src/bin/cargo/commands/metadata.rs @@ -26,7 +26,9 @@ pub fn cli() -> Command { .arg_quiet() .arg_features() .arg_manifest_path() - .after_help("Run `cargo help metadata` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help metadata` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/new.rs b/src/bin/cargo/commands/new.rs index 6124444c0..a5dff2721 100644 --- a/src/bin/cargo/commands/new.rs +++ b/src/bin/cargo/commands/new.rs @@ -9,7 +9,9 @@ pub fn cli() -> Command { .arg_new_opts() .arg(opt("registry", "Registry to use").value_name("REGISTRY")) .arg_quiet() - .after_help("Run `cargo help new` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help new` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/owner.rs b/src/bin/cargo/commands/owner.rs index 223327c31..c9deaef51 100644 --- a/src/bin/cargo/commands/owner.rs +++ b/src/bin/cargo/commands/owner.rs @@ -28,7 +28,9 @@ pub fn cli() -> Command { .arg(opt("token", "API token to use when authenticating").value_name("TOKEN")) .arg(opt("registry", "Registry to use").value_name("REGISTRY")) .arg_quiet() - .after_help("Run `cargo help owner` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help owner` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/package.rs b/src/bin/cargo/commands/package.rs index 7fa993f1d..0020e365e 100644 --- a/src/bin/cargo/commands/package.rs +++ b/src/bin/cargo/commands/package.rs @@ -35,7 +35,9 @@ pub fn cli() -> Command { .arg_target_dir() .arg_parallel() .arg_manifest_path() - .after_help("Run `cargo help package` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help package` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/pkgid.rs b/src/bin/cargo/commands/pkgid.rs index ba4540cf1..9d7a6c712 100644 --- a/src/bin/cargo/commands/pkgid.rs +++ b/src/bin/cargo/commands/pkgid.rs @@ -10,7 +10,9 @@ pub fn cli() -> Command { .arg_quiet() .arg_package("Argument to get the package ID specifier for") .arg_manifest_path() - .after_help("Run `cargo help pkgid` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help pkgid` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/publish.rs b/src/bin/cargo/commands/publish.rs index 8a9175f6c..34108d45d 100644 --- a/src/bin/cargo/commands/publish.rs +++ b/src/bin/cargo/commands/publish.rs @@ -24,7 +24,9 @@ pub fn cli() -> Command { .arg_target_triple("Build for the target triple") .arg_target_dir() .arg_manifest_path() - .after_help("Run `cargo help publish` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help publish` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/read_manifest.rs b/src/bin/cargo/commands/read_manifest.rs index a1f42bfb0..6625d60f5 100644 --- a/src/bin/cargo/commands/read_manifest.rs +++ b/src/bin/cargo/commands/read_manifest.rs @@ -2,13 +2,13 @@ use crate::command_prelude::*; pub fn cli() -> Command { subcommand("read-manifest") - .about( + .about(color_print::cstr!( "\ Print a JSON representation of a Cargo.toml manifest. -Deprecated, use `cargo metadata --no-deps` instead.\ -", - ) +Deprecated, use `cargo metadata --no-deps` instead.\ +" + )) .arg_quiet() .arg_manifest_path() } diff --git a/src/bin/cargo/commands/remove.rs b/src/bin/cargo/commands/remove.rs index b353609cb..aebb2f11c 100644 --- a/src/bin/cargo/commands/remove.rs +++ b/src/bin/cargo/commands/remove.rs @@ -50,7 +50,9 @@ pub fn cli() -> clap::Command { ]) .arg_package("Package to remove from") .arg_manifest_path() - .after_help("Run `cargo help remove` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help remove` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/report.rs b/src/bin/cargo/commands/report.rs index 275a8f7c0..adc4dcb92 100644 --- a/src/bin/cargo/commands/report.rs +++ b/src/bin/cargo/commands/report.rs @@ -5,7 +5,9 @@ use cargo::drop_println; pub fn cli() -> Command { subcommand("report") .about("Generate and display various kinds of reports") - .after_help("Run `cargo help report` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help report` for more detailed information.\n" + )) .subcommand_required(true) .arg_required_else_help(true) .subcommand( diff --git a/src/bin/cargo/commands/run.rs b/src/bin/cargo/commands/run.rs index ce2099b0e..029c9ee56 100644 --- a/src/bin/cargo/commands/run.rs +++ b/src/bin/cargo/commands/run.rs @@ -38,7 +38,9 @@ pub fn cli() -> Command { .arg_manifest_path() .arg_unit_graph() .arg_timings() - .after_help("Run `cargo help run` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help run` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/rustc.rs b/src/bin/cargo/commands/rustc.rs index d318b6194..60f0b9d60 100644 --- a/src/bin/cargo/commands/rustc.rs +++ b/src/bin/cargo/commands/rustc.rs @@ -52,7 +52,9 @@ pub fn cli() -> Command { .arg_unit_graph() .arg_timings() .arg_manifest_path() - .after_help("Run `cargo help rustc` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help rustc` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/rustdoc.rs b/src/bin/cargo/commands/rustdoc.rs index 25ca7dacf..8cb2f10de 100644 --- a/src/bin/cargo/commands/rustdoc.rs +++ b/src/bin/cargo/commands/rustdoc.rs @@ -40,7 +40,9 @@ pub fn cli() -> Command { .arg_unit_graph() .arg_timings() .arg_manifest_path() - .after_help("Run `cargo help rustdoc` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help rustdoc` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/search.rs b/src/bin/cargo/commands/search.rs index 656172e77..90aadcb27 100644 --- a/src/bin/cargo/commands/search.rs +++ b/src/bin/cargo/commands/search.rs @@ -18,7 +18,9 @@ pub fn cli() -> Command { .arg_index() .arg(opt("registry", "Registry to use").value_name("REGISTRY")) .arg_quiet() - .after_help("Run `cargo help search` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help search` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/test.rs b/src/bin/cargo/commands/test.rs index f8ec0e2f9..3c7af506d 100644 --- a/src/bin/cargo/commands/test.rs +++ b/src/bin/cargo/commands/test.rs @@ -57,10 +57,10 @@ pub fn cli() -> Command { .arg_unit_graph() .arg_timings() .arg_manifest_path() - .after_help( - "Run `cargo help test` for more detailed information.\n\ - Run `cargo test -- --help` for test binary options.\n", - ) + .after_help(color_print::cstr!( + "Run `cargo help test` for more detailed information.\n\ + Run `cargo test -- --help` for test binary options.\n", + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/tree.rs b/src/bin/cargo/commands/tree.rs index 4657eafff..1fe6a3a14 100644 --- a/src/bin/cargo/commands/tree.rs +++ b/src/bin/cargo/commands/tree.rs @@ -96,7 +96,9 @@ pub fn cli() -> Command { Pass `all` to include all targets.", ) .arg_manifest_path() - .after_help("Run `cargo help tree` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help tree` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/uninstall.rs b/src/bin/cargo/commands/uninstall.rs index 398979bf4..9585d290b 100644 --- a/src/bin/cargo/commands/uninstall.rs +++ b/src/bin/cargo/commands/uninstall.rs @@ -13,7 +13,9 @@ pub fn cli() -> Command { multi_opt("bin", "NAME", "Only uninstall the binary NAME") .help_heading(heading::TARGET_SELECTION), ) - .after_help("Run `cargo help uninstall` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help uninstall` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/update.rs b/src/bin/cargo/commands/update.rs index 1749de763..e06e8e51e 100644 --- a/src/bin/cargo/commands/update.rs +++ b/src/bin/cargo/commands/update.rs @@ -42,7 +42,9 @@ pub fn cli() -> Command { .help_heading(heading::PACKAGE_SELECTION), ) .arg_manifest_path() - .after_help("Run `cargo help update` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help update` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/vendor.rs b/src/bin/cargo/commands/vendor.rs index f0c1ecad0..05e0d7def 100644 --- a/src/bin/cargo/commands/vendor.rs +++ b/src/bin/cargo/commands/vendor.rs @@ -38,7 +38,9 @@ pub fn cli() -> Command { .arg(unsupported("disallow-duplicates")) .arg_quiet() .arg_manifest_path() - .after_help("Run `cargo help vendor` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help vendor` for more detailed information.\n" + )) } fn unsupported(name: &'static str) -> Arg { diff --git a/src/bin/cargo/commands/verify_project.rs b/src/bin/cargo/commands/verify_project.rs index 4d5492606..35bb747a4 100644 --- a/src/bin/cargo/commands/verify_project.rs +++ b/src/bin/cargo/commands/verify_project.rs @@ -8,7 +8,9 @@ pub fn cli() -> Command { .about("Check correctness of crate manifest") .arg_quiet() .arg_manifest_path() - .after_help("Run `cargo help verify-project` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help verify-project` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/version.rs b/src/bin/cargo/commands/version.rs index ac1681f5b..65e1c6c47 100644 --- a/src/bin/cargo/commands/version.rs +++ b/src/bin/cargo/commands/version.rs @@ -5,7 +5,9 @@ pub fn cli() -> Command { subcommand("version") .about("Show version information") .arg_quiet() - .after_help("Run `cargo help version` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help version` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/yank.rs b/src/bin/cargo/commands/yank.rs index e6700bd2f..665683915 100644 --- a/src/bin/cargo/commands/yank.rs +++ b/src/bin/cargo/commands/yank.rs @@ -20,7 +20,9 @@ pub fn cli() -> Command { .arg(opt("registry", "Registry to use").value_name("REGISTRY")) .arg(opt("token", "API token to use when authenticating").value_name("TOKEN")) .arg_quiet() - .after_help("Run `cargo help yank` for more detailed information.\n") + .after_help(color_print::cstr!( + "Run `cargo help yank` for more detailed information.\n" + )) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {