Skip to content

Commit

Permalink
Auto merge of #14631 - weihanglo:config-cli, r=epage
Browse files Browse the repository at this point in the history
docs(config): make `--config <PATH>` more prominent
  • Loading branch information
bors committed Oct 1, 2024
2 parents 135ea1c + b4253e5 commit 8fdd7f4
Show file tree
Hide file tree
Showing 41 changed files with 789 additions and 734 deletions.
2 changes: 1 addition & 1 deletion src/bin/cargo/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ See '<cyan,bold>cargo help</> <cyan><<command>></>' 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("")
Expand Down
15 changes: 9 additions & 6 deletions src/doc/src/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand Down
74 changes: 38 additions & 36 deletions tests/testsuite/cargo/help/stdout.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_add/help/stdout.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8fdd7f4

Please sign in to comment.