refactor(cli): Manually implement missing arg error for --target

This commit is contained in:
Ed Page 2023-08-30 20:42:45 -05:00
parent ca173bc32d
commit b87c9323bb
17 changed files with 25 additions and 21 deletions

View File

@ -218,7 +218,10 @@ pub trait CommandExt: Sized {
}
fn arg_target_triple(self, target: &'static str) -> Self {
self._arg(multi_opt("target", "TRIPLE", target).help_heading(heading::COMPILATION_OPTIONS))
self._arg(
optional_multi_opt("target", "TRIPLE", target)
.help_heading(heading::COMPILATION_OPTIONS),
)
}
fn arg_target_dir(self) -> Self {
@ -441,6 +444,9 @@ pub trait ArgMatchesExt {
}
fn targets(&self) -> CargoResult<Vec<String>> {
if self.is_present_with_zero_values("target") {
bail!("\"--target\" takes an argument.");
}
Ok(self._values_of("target"))
}

View File

@ -45,7 +45,7 @@ Feature Selection:
Compilation Options:
-j, --jobs <N> Number of parallel jobs, defaults to # of CPUs.
--profile <PROFILE-NAME> Build artifacts with the specified profile
--target <TRIPLE> Build for the target triple
--target [<TRIPLE>] Build for the target triple
--target-dir <DIRECTORY> Directory for all generated artifacts
--unit-graph Output build graph in JSON (unstable)
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json

View File

@ -42,7 +42,7 @@ Compilation Options:
--profile <PROFILE-NAME> Build artifacts with the specified profile
-j, --jobs <N> Number of parallel jobs, defaults to # of CPUs.
--keep-going Do not abort the build as soon as there is an error
--target <TRIPLE> Build for the target triple
--target [<TRIPLE>] Build for the target triple
--target-dir <DIRECTORY> Directory for all generated artifacts
--out-dir <PATH> Copy final artifacts to this directory (unstable)
--build-plan Output the build plan in JSON (unstable)

View File

@ -42,7 +42,7 @@ Compilation Options:
--keep-going Do not abort the build as soon as there is an error
-r, --release Check artifacts in release mode, with optimizations
--profile <PROFILE-NAME> Check artifacts with the specified profile
--target <TRIPLE> Check for the target triple
--target [<TRIPLE>] Check for the target triple
--target-dir <DIRECTORY> Directory for all generated artifacts
--unit-graph Output build graph in JSON (unstable)
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json

View File

@ -17,7 +17,7 @@ Package Selection:
Compilation Options:
-r, --release Whether or not to clean release artifacts
--profile <PROFILE-NAME> Clean artifacts of the specified profile
--target <TRIPLE> Target triple to clean output for
--target [<TRIPLE>] Target triple to clean output for
--target-dir <DIRECTORY> Directory for all generated artifacts
Manifest Options:

View File

@ -39,7 +39,7 @@ Compilation Options:
--keep-going Do not abort the build as soon as there is an error
-r, --release Build artifacts in release mode, with optimizations
--profile <PROFILE-NAME> Build artifacts with the specified profile
--target <TRIPLE> Build for the target triple
--target [<TRIPLE>] Build for the target triple
--target-dir <DIRECTORY> Directory for all generated artifacts
--unit-graph Output build graph in JSON (unstable)
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json

View File

@ -11,7 +11,7 @@ Options:
-h, --help Print help
Compilation Options:
--target <TRIPLE> Fetch dependencies for the target triple
--target [<TRIPLE>] Fetch dependencies for the target triple
Manifest Options:
--manifest-path <PATH> Path to Cargo.toml

View File

@ -47,7 +47,7 @@ Compilation Options:
--keep-going Do not abort the build as soon as there is an error
-r, --release Fix artifacts in release mode, with optimizations
--profile <PROFILE-NAME> Build artifacts with the specified profile
--target <TRIPLE> Fix for the target triple
--target [<TRIPLE>] Fix for the target triple
--target-dir <DIRECTORY> Directory for all generated artifacts
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json

View File

@ -44,7 +44,7 @@ Compilation Options:
-j, --jobs <N> Number of parallel jobs, defaults to # of CPUs.
--keep-going Do not abort the build as soon as there is an error
--profile <PROFILE-NAME> Install artifacts with the specified profile
--target <TRIPLE> Build for the target triple
--target [<TRIPLE>] Build for the target triple
--target-dir <DIRECTORY> Directory for all generated artifacts
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json

View File

@ -25,7 +25,7 @@ Feature Selection:
--no-default-features Do not activate the `default` feature
Compilation Options:
--target <TRIPLE> Build for the target triple
--target [<TRIPLE>] Build for the target triple
--target-dir <DIRECTORY> Directory for all generated artifacts
-j, --jobs <N> Number of parallel jobs, defaults to # of CPUs.
--keep-going Do not abort the build as soon as there is an error

View File

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

View File

@ -33,7 +33,7 @@ Compilation Options:
--keep-going Do not abort the build as soon as there is an error
-r, --release Build artifacts in release mode, with optimizations
--profile <PROFILE-NAME> Build artifacts with the specified profile
--target <TRIPLE> Build for the target triple
--target [<TRIPLE>] Build for the target triple
--target-dir <DIRECTORY> Directory for all generated artifacts
--unit-graph Output build graph in JSON (unstable)
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json

View File

@ -44,7 +44,7 @@ Compilation Options:
--keep-going Do not abort the build as soon as there is an error
-r, --release Build artifacts in release mode, with optimizations
--profile <PROFILE-NAME> Build artifacts with the specified profile
--target <TRIPLE> Target triple which compiles will be for
--target [<TRIPLE>] Target triple which compiles will be for
--target-dir <DIRECTORY> Directory for all generated artifacts
--unit-graph Output build graph in JSON (unstable)
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json

View File

@ -42,7 +42,7 @@ Compilation Options:
--keep-going Do not abort the build as soon as there is an error
-r, --release Build artifacts in release mode, with optimizations
--profile <PROFILE-NAME> Build artifacts with the specified profile
--target <TRIPLE> Build for the target triple
--target [<TRIPLE>] Build for the target triple
--target-dir <DIRECTORY> Directory for all generated artifacts
--unit-graph Output build graph in JSON (unstable)
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json

View File

@ -48,7 +48,7 @@ Compilation Options:
-j, --jobs <N> Number of parallel jobs, defaults to # of CPUs.
-r, --release Build artifacts in release mode, with optimizations
--profile <PROFILE-NAME> Build artifacts with the specified profile
--target <TRIPLE> Build for the target triple
--target [<TRIPLE>] Build for the target triple
--target-dir <DIRECTORY> Directory for all generated artifacts
--unit-graph Output build graph in JSON (unstable)
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json

View File

@ -33,7 +33,7 @@ Feature Selection:
--no-default-features Do not activate the `default` feature
Compilation Options:
--target <TRIPLE> Filter dependencies matching the given target-triple (default host
--target [<TRIPLE>] Filter dependencies matching the given target-triple (default host
platform). Pass `all` to include all targets.
Manifest Options:

View File

@ -166,12 +166,10 @@ No tests available.
.cargo(&format!("{} --target", command))
.with_stderr(
"\
error: a value is required for '--target <TRIPLE>' but none was supplied
For more information, try '--help'.
error: \"--target\" takes an argument.
",
)
.with_status(1)
.with_status(101)
.run();
}
}