Skip to content

Commit 8fdd7f4

Browse files
committed
Auto merge of #14631 - weihanglo:config-cli, r=epage
docs(config): make `--config <PATH>` more prominent
2 parents 135ea1c + b4253e5 commit 8fdd7f4

File tree

41 files changed

+789
-734
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+789
-734
lines changed

src/bin/cargo/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ See '<cyan,bold>cargo help</> <cyan><<command>></>' for more information on a sp
668668
.action(ArgAction::SetTrue)
669669
.global(true)
670670
.hide(true))
671-
.arg(multi_opt("config", "KEY=VALUE", "Override a configuration value").global(true))
671+
.arg(multi_opt("config", "KEY=VALUE|PATH", "Override a configuration value").global(true))
672672
// Better suggestion for the unsupported lowercase unstable feature flag.
673673
.arg( Arg::new("unsupported-lowercase-unstable-feature-flag")
674674
.help("")

src/doc/src/reference/config.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,14 @@ In addition to the system above, Cargo recognizes a few other specific
220220

221221
Cargo also accepts arbitrary configuration overrides through the
222222
`--config` command-line option. The argument should be in TOML syntax of
223-
`KEY=VALUE`:
223+
`KEY=VALUE` or provided as a path to an extra configuration file:
224224

225225
```console
226+
# With `KEY=VALUE` in TOML syntax
226227
cargo --config net.git-fetch-with-cli=true fetch
228+
229+
# With a path to a configuration file
230+
cargo --config ./path/to/my/extra-config.toml fetch
227231
```
228232

229233
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
232236
values specified this way take precedence over environment variables,
233237
which take precedence over configuration files.
234238

239+
When the `--config` option is provided as an extra configuration file,
240+
The configuration file loaded this way follow the same precedence rules
241+
as other options specified directly with `--config`.
242+
235243
Some examples of what it looks like using Bourne shell syntax:
236244

237245
```console
@@ -251,11 +259,6 @@ cargo --config "target.'cfg(all(target_arch = \"arm\", target_os = \"none\"))'.r
251259
cargo --config profile.dev.package.image.opt-level=3 …
252260
```
253261

254-
The `--config` option can also be used to pass paths to extra
255-
configuration files that Cargo should use for a specific invocation.
256-
Options from configuration files loaded this way follow the same
257-
precedence rules as other options specified directly with `--config`.
258-
259262
## Config-relative paths
260263

261264
Paths in config files may be absolute, relative, or a bare name without any path separators.

tests/testsuite/cargo/help/stdout.term.svg

Lines changed: 38 additions & 36 deletions
Loading

tests/testsuite/cargo_add/help/stdout.term.svg

Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)