Skip to content

Commit 0bcac2e

Browse files
authored
Add -m shorthand for --manifest-path (#16858)
### What does this PR try to resolve? * Solves #16726 ### How to test and review this PR? * In cases where you would expect `--manifest-path` to work, try `-m` instead. --- ### Notes * First time contributing to `cargo` so please let me know what I can do to bring this PR up to par if I've missed anything! * No AI tooling of any kind was used in the creation of this PR.
2 parents b0f187b + 53e8ba1 commit 0bcac2e

28 files changed

Lines changed: 41 additions & 27 deletions

File tree

src/cargo/util/command_prelude.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ pub trait CommandExt: Sized {
375375
fn arg_manifest_path_without_unsupported_path_tip(self) -> Self {
376376
self._arg(
377377
opt("manifest-path", "Path to Cargo.toml")
378+
.short('m')
378379
.value_name("PATH")
379380
.help_heading(heading::MANIFEST_OPTIONS)
380381
.add(clap_complete::engine::ArgValueCompleter::new(

tests/testsuite/build.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,19 @@ For more information, try '--help'.
293293
.run();
294294
}
295295

296+
#[cargo_test]
297+
fn cargo_compile_with_manifest_path_shorthand() {
298+
let p = project()
299+
.file("Cargo.toml", &basic_bin_manifest("foo"))
300+
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
301+
.build();
302+
303+
p.cargo("build -m foo/Cargo.toml")
304+
.cwd(p.root().parent().unwrap())
305+
.run();
306+
assert!(p.bin("foo").is_file());
307+
}
308+
296309
#[cargo_test]
297310
fn chdir_gated() {
298311
let p = project()

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

Lines changed: 1 addition & 1 deletion
Loading

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

Lines changed: 1 addition & 1 deletion
Loading

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

Lines changed: 1 addition & 1 deletion
Loading

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

Lines changed: 1 addition & 1 deletion
Loading

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

Lines changed: 1 addition & 1 deletion
Loading

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

Lines changed: 1 addition & 1 deletion
Loading

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

Lines changed: 1 addition & 1 deletion
Loading

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

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)