Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(config): make --config <PATH> more prominent #14631

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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