Skip to content

Commit b87c932

Browse files
committed
refactor(cli): Manually implement missing arg error for --target
1 parent ca173bc commit b87c932

File tree

17 files changed

+25
-21
lines changed

17 files changed

+25
-21
lines changed

src/cargo/util/command_prelude.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,10 @@ pub trait CommandExt: Sized {
218218
}
219219

220220
fn arg_target_triple(self, target: &'static str) -> Self {
221-
self._arg(multi_opt("target", "TRIPLE", target).help_heading(heading::COMPILATION_OPTIONS))
221+
self._arg(
222+
optional_multi_opt("target", "TRIPLE", target)
223+
.help_heading(heading::COMPILATION_OPTIONS),
224+
)
222225
}
223226

224227
fn arg_target_dir(self) -> Self {
@@ -441,6 +444,9 @@ pub trait ArgMatchesExt {
441444
}
442445

443446
fn targets(&self) -> CargoResult<Vec<String>> {
447+
if self.is_present_with_zero_values("target") {
448+
bail!("\"--target\" takes an argument.");
449+
}
444450
Ok(self._values_of("target"))
445451
}
446452

tests/testsuite/cargo_bench/help/stdout.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Feature Selection:
4545
Compilation Options:
4646
-j, --jobs <N> Number of parallel jobs, defaults to # of CPUs.
4747
--profile <PROFILE-NAME> Build artifacts with the specified profile
48-
--target <TRIPLE> Build for the target triple
48+
--target [<TRIPLE>] Build for the target triple
4949
--target-dir <DIRECTORY> Directory for all generated artifacts
5050
--unit-graph Output build graph in JSON (unstable)
5151
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json

tests/testsuite/cargo_build/help/stdout.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Compilation Options:
4242
--profile <PROFILE-NAME> Build artifacts with the specified profile
4343
-j, --jobs <N> Number of parallel jobs, defaults to # of CPUs.
4444
--keep-going Do not abort the build as soon as there is an error
45-
--target <TRIPLE> Build for the target triple
45+
--target [<TRIPLE>] Build for the target triple
4646
--target-dir <DIRECTORY> Directory for all generated artifacts
4747
--out-dir <PATH> Copy final artifacts to this directory (unstable)
4848
--build-plan Output the build plan in JSON (unstable)

tests/testsuite/cargo_check/help/stdout.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Compilation Options:
4242
--keep-going Do not abort the build as soon as there is an error
4343
-r, --release Check artifacts in release mode, with optimizations
4444
--profile <PROFILE-NAME> Check artifacts with the specified profile
45-
--target <TRIPLE> Check for the target triple
45+
--target [<TRIPLE>] Check for the target triple
4646
--target-dir <DIRECTORY> Directory for all generated artifacts
4747
--unit-graph Output build graph in JSON (unstable)
4848
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json

tests/testsuite/cargo_clean/help/stdout.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Package Selection:
1717
Compilation Options:
1818
-r, --release Whether or not to clean release artifacts
1919
--profile <PROFILE-NAME> Clean artifacts of the specified profile
20-
--target <TRIPLE> Target triple to clean output for
20+
--target [<TRIPLE>] Target triple to clean output for
2121
--target-dir <DIRECTORY> Directory for all generated artifacts
2222

2323
Manifest Options:

tests/testsuite/cargo_doc/help/stdout.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Compilation Options:
3939
--keep-going Do not abort the build as soon as there is an error
4040
-r, --release Build artifacts in release mode, with optimizations
4141
--profile <PROFILE-NAME> Build artifacts with the specified profile
42-
--target <TRIPLE> Build for the target triple
42+
--target [<TRIPLE>] Build for the target triple
4343
--target-dir <DIRECTORY> Directory for all generated artifacts
4444
--unit-graph Output build graph in JSON (unstable)
4545
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json

tests/testsuite/cargo_fetch/help/stdout.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Options:
1111
-h, --help Print help
1212

1313
Compilation Options:
14-
--target <TRIPLE> Fetch dependencies for the target triple
14+
--target [<TRIPLE>] Fetch dependencies for the target triple
1515

1616
Manifest Options:
1717
--manifest-path <PATH> Path to Cargo.toml

tests/testsuite/cargo_fix/help/stdout.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Compilation Options:
4747
--keep-going Do not abort the build as soon as there is an error
4848
-r, --release Fix artifacts in release mode, with optimizations
4949
--profile <PROFILE-NAME> Build artifacts with the specified profile
50-
--target <TRIPLE> Fix for the target triple
50+
--target [<TRIPLE>] Fix for the target triple
5151
--target-dir <DIRECTORY> Directory for all generated artifacts
5252
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json
5353

tests/testsuite/cargo_install/help/stdout.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Compilation Options:
4444
-j, --jobs <N> Number of parallel jobs, defaults to # of CPUs.
4545
--keep-going Do not abort the build as soon as there is an error
4646
--profile <PROFILE-NAME> Install artifacts with the specified profile
47-
--target <TRIPLE> Build for the target triple
47+
--target [<TRIPLE>] Build for the target triple
4848
--target-dir <DIRECTORY> Directory for all generated artifacts
4949
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json
5050

tests/testsuite/cargo_package/help/stdout.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Feature Selection:
2525
--no-default-features Do not activate the `default` feature
2626

2727
Compilation Options:
28-
--target <TRIPLE> Build for the target triple
28+
--target [<TRIPLE>] Build for the target triple
2929
--target-dir <DIRECTORY> Directory for all generated artifacts
3030
-j, --jobs <N> Number of parallel jobs, defaults to # of CPUs.
3131
--keep-going Do not abort the build as soon as there is an error

0 commit comments

Comments
 (0)