From ea9c75a54cbd87dd786fc7c69e1104b14b2ab1b8 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Mon, 8 Jan 2024 20:25:44 -0500 Subject: [PATCH] refactor(cli): tweak to align existing style --- src/bin/cargo/cli.rs | 6 +-- tests/testsuite/cargo/z_help/stdout.log | 63 ++++++++++++------------- tests/testsuite/help.rs | 16 +++---- 3 files changed, 42 insertions(+), 43 deletions(-) diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index 129d3f1bd844..cefa971a6c71 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -76,7 +76,7 @@ pub fn main(config: &mut LazyConfig) -> CliResult { .map(|(option_name, option_help_message)| { let option_name_kebab_case = option_name.replace("_", "-"); format!( - " {literal}-Z {: CliResult { let joined = help_lines.join("\n"); drop_println!( config, - " + "\ {header}Available unstable (nightly-only) flags:{reset} {} -Run with '{literal}cargo -Z{reset} {placeholder}[FLAG] [COMMAND]{reset}'", +Run with `{literal}cargo -Z{reset} {placeholder}[FLAG] [COMMAND]{reset}`", joined ); if !config.nightly_features_allowed { diff --git a/tests/testsuite/cargo/z_help/stdout.log b/tests/testsuite/cargo/z_help/stdout.log index 8257e3ec9f08..109ca7685da5 100644 --- a/tests/testsuite/cargo/z_help/stdout.log +++ b/tests/testsuite/cargo/z_help/stdout.log @@ -1,37 +1,36 @@ - Available unstable (nightly-only) flags: - -Z allow-features -- Allow *only* the listed unstable features - -Z asymmetric-token -- Allows authenticating with asymmetric tokens - -Z avoid-dev-deps -- Avoid installing dev-dependencies if possible - -Z binary-dep-depinfo -- Track changes to dependency artifacts - -Z bindeps -- Allow Cargo packages to depend on bin, cdylib, and staticlib crates, and use the artifacts built by those crates - -Z build-std -- Enable Cargo to compile the standard library itself as part of a crate graph compilation - -Z build-std-features -- Configure features enabled for the standard library itself when building the standard library - -Z check-cfg -- Enable compile-time checking of `cfg` names/values/features - -Z codegen-backend -- Enable the `codegen-backend` option in profiles in .cargo/config.toml file - -Z config-include -- Enable the `include` key in config files - -Z direct-minimal-versions -- Resolve minimal dependency versions instead of maximum (direct dependencies only) - -Z doctest-xcompile -- Compile and run doctests for non-host target using runner config - -Z dual-proc-macros -- Build proc-macros for both the host and the target - -Z gc -- Track cache usage and "garbage collect" unused files - -Z gitoxide -- Use gitoxide for the given git interactions, or all of them if no argument is given - -Z host-config -- Enable the [host] section in the .cargo/config.toml file - -Z lints -- Pass `[lints]` to the linting tools - -Z minimal-versions -- Resolve minimal dependency versions instead of maximum - -Z msrv-policy -- Enable rust-version aware policy within cargo - -Z mtime-on-use -- Configure Cargo to update the mtime of used files - -Z no-index-update -- Do not update the registry index even if the cache is outdated - -Z panic-abort-tests -- Enable support to run tests with -Cpanic=abort - -Z profile-rustflags -- Enable the `rustflags` option in profiles in .cargo/config.toml file - -Z publish-timeout -- Enable the `publish.timeout` key in .cargo/config.toml file - -Z rustdoc-map -- Allow passing external documentation mappings to rustdoc - -Z rustdoc-scrape-examples -- Allows Rustdoc to scrape code examples from reverse-dependencies - -Z script -- Enable support for single-file, `.rs` packages - -Z target-applies-to-host -- Enable the `target-applies-to-host` key in the .cargo/config.toml file - -Z trim-paths -- Enable the `trim-paths` option in profiles - -Z unstable-options -- Allow the usage of unstable options + -Z allow-features Allow *only* the listed unstable features + -Z asymmetric-token Allows authenticating with asymmetric tokens + -Z avoid-dev-deps Avoid installing dev-dependencies if possible + -Z binary-dep-depinfo Track changes to dependency artifacts + -Z bindeps Allow Cargo packages to depend on bin, cdylib, and staticlib crates, and use the artifacts built by those crates + -Z build-std Enable Cargo to compile the standard library itself as part of a crate graph compilation + -Z build-std-features Configure features enabled for the standard library itself when building the standard library + -Z check-cfg Enable compile-time checking of `cfg` names/values/features + -Z codegen-backend Enable the `codegen-backend` option in profiles in .cargo/config.toml file + -Z config-include Enable the `include` key in config files + -Z direct-minimal-versions Resolve minimal dependency versions instead of maximum (direct dependencies only) + -Z doctest-xcompile Compile and run doctests for non-host target using runner config + -Z dual-proc-macros Build proc-macros for both the host and the target + -Z gc Track cache usage and "garbage collect" unused files + -Z gitoxide Use gitoxide for the given git interactions, or all of them if no argument is given + -Z host-config Enable the [host] section in the .cargo/config.toml file + -Z lints Pass `[lints]` to the linting tools + -Z minimal-versions Resolve minimal dependency versions instead of maximum + -Z msrv-policy Enable rust-version aware policy within cargo + -Z mtime-on-use Configure Cargo to update the mtime of used files + -Z no-index-update Do not update the registry index even if the cache is outdated + -Z panic-abort-tests Enable support to run tests with -Cpanic=abort + -Z profile-rustflags Enable the `rustflags` option in profiles in .cargo/config.toml file + -Z publish-timeout Enable the `publish.timeout` key in .cargo/config.toml file + -Z rustdoc-map Allow passing external documentation mappings to rustdoc + -Z rustdoc-scrape-examples Allows Rustdoc to scrape code examples from reverse-dependencies + -Z script Enable support for single-file, `.rs` packages + -Z target-applies-to-host Enable the `target-applies-to-host` key in the .cargo/config.toml file + -Z trim-paths Enable the `trim-paths` option in profiles + -Z unstable-options Allow the usage of unstable options -Run with 'cargo -Z [FLAG] [COMMAND]' +Run with `cargo -Z [FLAG] [COMMAND]` See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html for more information about these flags. diff --git a/tests/testsuite/help.rs b/tests/testsuite/help.rs index 646d8e4c70db..25fcbd26d66d 100644 --- a/tests/testsuite/help.rs +++ b/tests/testsuite/help.rs @@ -160,49 +160,49 @@ fn help_alias() { fn alias_z_flag_help() { cargo_process("build -Z help") .with_stdout_contains( - " -Z allow-features[..]-- Allow *only* the listed unstable features", + " -Z allow-features[..] Allow *only* the listed unstable features", ) .run(); cargo_process("run -Z help") .with_stdout_contains( - " -Z allow-features[..]-- Allow *only* the listed unstable features", + " -Z allow-features[..] Allow *only* the listed unstable features", ) .run(); cargo_process("check -Z help") .with_stdout_contains( - " -Z allow-features[..]-- Allow *only* the listed unstable features", + " -Z allow-features[..] Allow *only* the listed unstable features", ) .run(); cargo_process("test -Z help") .with_stdout_contains( - " -Z allow-features[..]-- Allow *only* the listed unstable features", + " -Z allow-features[..] Allow *only* the listed unstable features", ) .run(); cargo_process("b -Z help") .with_stdout_contains( - " -Z allow-features[..]-- Allow *only* the listed unstable features", + " -Z allow-features[..] Allow *only* the listed unstable features", ) .run(); cargo_process("r -Z help") .with_stdout_contains( - " -Z allow-features[..]-- Allow *only* the listed unstable features", + " -Z allow-features[..] Allow *only* the listed unstable features", ) .run(); cargo_process("c -Z help") .with_stdout_contains( - " -Z allow-features[..]-- Allow *only* the listed unstable features", + " -Z allow-features[..] Allow *only* the listed unstable features", ) .run(); cargo_process("t -Z help") .with_stdout_contains( - " -Z allow-features[..]-- Allow *only* the listed unstable features", + " -Z allow-features[..] Allow *only* the listed unstable features", ) .run(); }