Skip to content

Commit 3afc004

Browse files
committed
Show available profiles on error
1 parent d3d3397 commit 3afc004

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/bootstrap/flags.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,14 @@ Arguments:
542542
|path| format!("{} is not a valid UTF8 string", path.to_string_lossy())
543543
));
544544

545-
profile_string.parse().expect("unknown profile")
545+
profile_string.parse().unwrap_or_else(|_| {
546+
eprintln!("error: unknown profile {}", profile_string);
547+
eprintln!("help: the available profiles are:");
548+
for choice in Profile::all() {
549+
eprintln!("- {}", choice);
550+
}
551+
std::process::exit(1);
552+
})
546553
} else {
547554
t!(crate::setup::interactive_path())
548555
};

src/bootstrap/setup.rs

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ impl Profile {
1818
fn include_path(&self, src_path: &Path) -> PathBuf {
1919
PathBuf::from(format!("{}/src/bootstrap/defaults/config.{}.toml", src_path.display(), self))
2020
}
21+
22+
pub fn all() -> impl Iterator<Item = Self> {
23+
[Profile::Compiler, Profile::Codegen, Profile::Library, Profile::User].iter().copied()
24+
}
2125
}
2226

2327
#[derive(Debug)]

0 commit comments

Comments
 (0)