From 6269ab4dd9c15c1cc5086c454b54b50a2480c447 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Tue, 1 Oct 2024 14:22:00 -0400 Subject: [PATCH 1/2] docs(config): make `--config ` more prominent --- src/doc/src/reference/config.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/doc/src/reference/config.md b/src/doc/src/reference/config.md index aab0097a57f..9360c3a5344 100644 --- a/src/doc/src/reference/config.md +++ b/src/doc/src/reference/config.md @@ -220,10 +220,14 @@ In addition to the system above, Cargo recognizes a few other specific Cargo also accepts arbitrary configuration overrides through the `--config` command-line option. The argument should be in TOML syntax of -`KEY=VALUE`: +`KEY=VALUE` or provided as a path to an extra configuration file: ```console +# With `KEY=VALUE` in TOML syntax cargo --config net.git-fetch-with-cli=true fetch + +# With a path to a configuration file +cargo --config ./path/to/my/extra-config.toml fetch ``` The `--config` option may be specified multiple times, in which case the @@ -232,6 +236,10 @@ that is used when multiple configuration files apply. Configuration values specified this way take precedence over environment variables, which take precedence over configuration files. +When the `--config` option is provided as an extra configuration file, +The configuration file loaded this way follow the same precedence rules +as other options specified directly with `--config`. + Some examples of what it looks like using Bourne shell syntax: ```console @@ -251,11 +259,6 @@ cargo --config "target.'cfg(all(target_arch = \"arm\", target_os = \"none\"))'.r cargo --config profile.dev.package.image.opt-level=3 … ``` -The `--config` option can also be used to pass paths to extra -configuration files that Cargo should use for a specific invocation. -Options from configuration files loaded this way follow the same -precedence rules as other options specified directly with `--config`. - ## Config-relative paths Paths in config files may be absolute, relative, or a bare name without any path separators. From b4253e505772bd32214bd7b5ce0e443194a07cb2 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Tue, 1 Oct 2024 14:25:03 -0400 Subject: [PATCH 2/2] fix(help): mention `--config ` in help text --- src/bin/cargo/cli.rs | 2 +- tests/testsuite/cargo/help/stdout.term.svg | 74 ++++++------ .../testsuite/cargo_add/help/stdout.term.svg | 4 +- .../cargo_bench/help/stdout.term.svg | 22 ++-- .../cargo_build/help/stdout.term.svg | 20 ++-- .../cargo_check/help/stdout.term.svg | 20 ++-- .../cargo_clean/help/stdout.term.svg | 58 +++++----- .../cargo_config/help/stdout.term.svg | 28 ++--- .../testsuite/cargo_doc/help/stdout.term.svg | 24 ++-- .../cargo_fetch/help/stdout.term.svg | 42 +++---- .../testsuite/cargo_fix/help/stdout.term.svg | 30 ++--- .../help/stdout.term.svg | 38 ++++--- .../testsuite/cargo_help/help/stdout.term.svg | 28 ++--- .../testsuite/cargo_info/help/stdout.term.svg | 42 +++---- .../testsuite/cargo_init/help/stdout.term.svg | 50 +++++---- .../cargo_install/help/stdout.term.svg | 106 +++++++++--------- .../cargo_locate_project/help/stdout.term.svg | 20 ++-- .../cargo_login/help/stdout.term.svg | 34 +++--- .../cargo_logout/help/stdout.term.svg | 34 +++--- .../cargo_metadata/help/stdout.term.svg | 2 +- .../testsuite/cargo_new/help/stdout.term.svg | 50 +++++---- .../cargo_owner/help/stdout.term.svg | 44 ++++---- .../cargo_package/help/stdout.term.svg | 80 ++++++------- .../cargo_pkgid/help/stdout.term.svg | 42 +++---- .../cargo_publish/help/stdout.term.svg | 76 +++++++------ .../cargo_read_manifest/help/stdout.term.svg | 30 ++--- .../cargo_remove/help/stdout.term.svg | 54 ++++----- .../cargo_report/help/stdout.term.svg | 32 +++--- .../testsuite/cargo_run/help/stdout.term.svg | 18 +-- .../cargo_rustc/help/stdout.term.svg | 2 +- .../cargo_rustdoc/help/stdout.term.svg | 22 ++-- .../cargo_search/help/stdout.term.svg | 38 ++++--- .../testsuite/cargo_test/help/stdout.term.svg | 24 ++-- .../testsuite/cargo_tree/help/stdout.term.svg | 86 +++++++------- .../cargo_uninstall/help/stdout.term.svg | 46 ++++---- .../cargo_update/help/stdout.term.svg | 54 ++++----- .../cargo_vendor/help/stdout.term.svg | 24 ++-- .../cargo_verify_project/help/stdout.term.svg | 34 +++--- .../cargo_version/help/stdout.term.svg | 32 +++--- .../testsuite/cargo_yank/help/stdout.term.svg | 42 +++---- 40 files changed, 780 insertions(+), 728 deletions(-) diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index 9cc0401a31c..aa72d7c1a3b 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -668,7 +668,7 @@ See 'cargo help <>' for more information on a sp .action(ArgAction::SetTrue) .global(true) .hide(true)) - .arg(multi_opt("config", "KEY=VALUE", "Override a configuration value").global(true)) + .arg(multi_opt("config", "KEY=VALUE|PATH", "Override a configuration value").global(true)) // Better suggestion for the unsupported lowercase unstable feature flag. .arg( Arg::new("unsupported-lowercase-unstable-feature-flag") .help("") diff --git a/tests/testsuite/cargo/help/stdout.term.svg b/tests/testsuite/cargo/help/stdout.term.svg index 19d2cee5410..1f85d99150d 100644 --- a/tests/testsuite/cargo/help/stdout.term.svg +++ b/tests/testsuite/cargo/help/stdout.term.svg @@ -1,4 +1,4 @@ - +