Skip to content

Commit 73bfbbb

Browse files
committed
Better suggestion for unsupported -path flag
Signed-off-by: hi-rustin <[email protected]>
1 parent 95d7909 commit 73bfbbb

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/cargo/util/command_prelude.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,24 @@ pub trait CommandExt: Sized {
267267
}
268268

269269
fn arg_manifest_path(self) -> Self {
270+
// We use `--manifest-path` instead of `--path`.
271+
let unsupported_path_arg = {
272+
let value_parser = UnknownArgumentValueParser::suggest_arg("--manifest-path");
273+
flag("unsupported-path-flag", "")
274+
.long("path")
275+
.value_parser(value_parser)
276+
.hide(true)
277+
};
278+
self._arg(
279+
opt("manifest-path", "Path to Cargo.toml")
280+
.value_name("PATH")
281+
.help_heading(heading::MANIFEST_OPTIONS),
282+
)
283+
._arg(unsupported_path_arg)
284+
}
285+
286+
// `cargo add` has a `--path` flag to install a crate from a local path.
287+
fn arg_manifest_path_without_unsupported_path_tip(self) -> Self {
270288
self._arg(
271289
opt("manifest-path", "Path to Cargo.toml")
272290
.value_name("PATH")

tests/testsuite/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ fn cargo_compile_with_wrong_manifest_path_flag() {
218218
"\
219219
error: unexpected argument '--path' found
220220
221+
tip: a similar argument exists: '--manifest-path'
222+
221223
Usage: cargo[EXE] build [OPTIONS]
222224
223225
For more information, try '--help'.

0 commit comments

Comments
 (0)