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

Stabilize config-cli #10755

Merged
merged 4 commits into from
Jun 22, 2022
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
9 changes: 1 addition & 8 deletions src/bin/cargo/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,7 @@ See 'cargo help <command>' for more information on a specific command.\n",
.arg(flag("frozen", "Require Cargo.lock and cache are up to date").global(true))
.arg(flag("locked", "Require Cargo.lock is up to date").global(true))
.arg(flag("offline", "Run without accessing the network").global(true))
.arg(
multi_opt(
"config",
"KEY=VALUE",
"Override a configuration value (unstable)",
)
.global(true),
)
.arg(multi_opt("config", "KEY=VALUE", "Override a configuration value").global(true))
.arg(
Arg::new("unstable-features")
.help("Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details")
Expand Down
7 changes: 3 additions & 4 deletions src/cargo/util/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,6 @@ impl Config {
self.unstable_flags_cli = Some(unstable_flags.to_vec());
}
if !cli_config.is_empty() {
self.unstable_flags.fail_if_stable_opt("--config", 6699)?;
self.cli_config = Some(cli_config.iter().map(|s| s.to_string()).collect());
self.merge_cli_args()?;
}
Expand Down Expand Up @@ -1165,6 +1164,7 @@ impl Config {
Some(cli_args) => cli_args,
None => return Ok(loaded_args),
};
let mut seen = HashSet::new();
for arg in cli_args {
let arg_as_path = self.cwd.join(arg);
let tmp_table = if !arg.is_empty() && arg_as_path.exists() {
Expand All @@ -1175,9 +1175,8 @@ impl Config {
anyhow::format_err!("config path {:?} is not utf-8", arg_as_path)
})?
.to_string();
let value = CV::String(str_path, Definition::Cli);
let map = HashMap::from([("include".to_string(), value)]);
CV::Table(map, Definition::Cli)
self._load_file(&self.cwd().join(&str_path), &mut seen, true)
.with_context(|| format!("failed to load config from `{}`", str_path))?
} else {
// We only want to allow "dotted key" (see https://toml.io/en/v1.0.0#keys)
// expressions followed by a value that's not an "inline table"
Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-add.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-bench.txt
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-check.txt
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-clean.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-fetch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-fix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-generate-lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-init.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-locate-project.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-login.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-new.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-owner.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-package.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-pkgid.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-publish.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-run.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-rustc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-rustdoc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-search.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-tree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-uninstall.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-update.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-verify-project.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-yank.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
4 changes: 4 additions & 0 deletions src/doc/man/includes/section-options-common.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ See the [rustup documentation](https://rust-lang.github.io/rustup/overrides.html
for more information about how toolchain overrides work.
{{/option}}

{{#option "`--config` KEY=VALUE"}}
Overrides a Cargo configuration value.
{{/option}}

{{#option "`-h`" "`--help`"}}
Prints help information.
{{/option}}
Expand Down
4 changes: 4 additions & 0 deletions src/doc/src/commands/cargo-add.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ See the <a href="https://rust-lang.github.io/rustup/overrides.html">rustup docum
for more information about how toolchain overrides work.</dd>


<dt class="option-term" id="option-cargo-add---config"><a class="option-anchor" href="#option-cargo-add---config"></a><code>--config</code> KEY=VALUE</dt>
<dd class="option-desc">Overrides a Cargo configuration value.</dd>


<dt class="option-term" id="option-cargo-add--h"><a class="option-anchor" href="#option-cargo-add--h"></a><code>-h</code></dt>
<dt class="option-term" id="option-cargo-add---help"><a class="option-anchor" href="#option-cargo-add---help"></a><code>--help</code></dt>
<dd class="option-desc">Prints help information.</dd>
Expand Down
4 changes: 4 additions & 0 deletions src/doc/src/commands/cargo-bench.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,10 @@ See the <a href="https://rust-lang.github.io/rustup/overrides.html">rustup docum
for more information about how toolchain overrides work.</dd>


<dt class="option-term" id="option-cargo-bench---config"><a class="option-anchor" href="#option-cargo-bench---config"></a><code>--config</code> KEY=VALUE</dt>
<dd class="option-desc">Overrides a Cargo configuration value.</dd>


<dt class="option-term" id="option-cargo-bench--h"><a class="option-anchor" href="#option-cargo-bench--h"></a><code>-h</code></dt>
<dt class="option-term" id="option-cargo-bench---help"><a class="option-anchor" href="#option-cargo-bench---help"></a><code>--help</code></dt>
<dd class="option-desc">Prints help information.</dd>
Expand Down
4 changes: 4 additions & 0 deletions src/doc/src/commands/cargo-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ See the <a href="https://rust-lang.github.io/rustup/overrides.html">rustup docum
for more information about how toolchain overrides work.</dd>


<dt class="option-term" id="option-cargo-build---config"><a class="option-anchor" href="#option-cargo-build---config"></a><code>--config</code> KEY=VALUE</dt>
<dd class="option-desc">Overrides a Cargo configuration value.</dd>


<dt class="option-term" id="option-cargo-build--h"><a class="option-anchor" href="#option-cargo-build--h"></a><code>-h</code></dt>
<dt class="option-term" id="option-cargo-build---help"><a class="option-anchor" href="#option-cargo-build---help"></a><code>--help</code></dt>
<dd class="option-desc">Prints help information.</dd>
Expand Down
Loading