Skip to content

Commit

Permalink
fix(cli): Help people find possible --target values
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Aug 31, 2023
1 parent fe37a36 commit 8156fcb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::core::{Edition, Workspace};
use crate::ops::{CompileFilter, CompileOptions, NewOptions, Packages, VersionControl};
use crate::util::important_paths::find_root_manifest_for_wd;
use crate::util::interning::InternedString;
use crate::util::is_rustup;
use crate::util::restricted_names::is_glob_pattern;
use crate::util::toml::{StringOrVec, TomlProfile};
use crate::util::validate_package_name;
Expand Down Expand Up @@ -445,7 +446,16 @@ pub trait ArgMatchesExt {

fn targets(&self) -> CargoResult<Vec<String>> {
if self.is_present_with_zero_values("target") {
bail!("\"--target\" takes an argument.");
let cmd = if is_rustup() {
"rustup target list"
} else {
"ustc --print target-list"
};
bail!(
"\"--target\" takes an argument.
Run `{cmd}` to see possible targets."
);
}
Ok(self._values_of("target"))
}
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/list_availables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ No tests available.
.with_stderr(
"\
error: \"--target\" takes an argument.
Run `[..]` to see possible targets.
",
)
.with_status(101)
Expand Down

0 comments on commit 8156fcb

Please sign in to comment.