diff options
| author | Antoine Martin <antoine97.martin@gmail.com> | 2020-10-05 17:55:14 +0200 |
|---|---|---|
| committer | Antoine Martin <antoine97.martin@gmail.com> | 2020-10-06 16:40:30 +0200 |
| commit | 3afc004845b36d18009718fe8d5179adfa1ca2ea (patch) | |
| tree | 08c8f0f2dc20e20080c87f63aaaedee99098a9e3 | |
| parent | d3d33971216f5eca3139e239c2b1f485c52270f4 (diff) | |
| download | rust-3afc004845b36d18009718fe8d5179adfa1ca2ea.tar.gz rust-3afc004845b36d18009718fe8d5179adfa1ca2ea.zip | |
Show available profiles on error
| -rw-r--r-- | src/bootstrap/flags.rs | 9 | ||||
| -rw-r--r-- | src/bootstrap/setup.rs | 4 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 2c1e361fae4..d1f256d6dd0 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -542,7 +542,14 @@ Arguments: |path| format!("{} is not a valid UTF8 string", path.to_string_lossy()) )); - profile_string.parse().expect("unknown profile") + profile_string.parse().unwrap_or_else(|_| { + eprintln!("error: unknown profile {}", profile_string); + eprintln!("help: the available profiles are:"); + for choice in Profile::all() { + eprintln!("- {}", choice); + } + std::process::exit(1); + }) } else { t!(crate::setup::interactive_path()) }; diff --git a/src/bootstrap/setup.rs b/src/bootstrap/setup.rs index cbbb406cd16..0d2945c3c39 100644 --- a/src/bootstrap/setup.rs +++ b/src/bootstrap/setup.rs @@ -18,6 +18,10 @@ impl Profile { fn include_path(&self, src_path: &Path) -> PathBuf { PathBuf::from(format!("{}/src/bootstrap/defaults/config.{}.toml", src_path.display(), self)) } + + pub fn all() -> impl Iterator<Item = Self> { + [Profile::Compiler, Profile::Codegen, Profile::Library, Profile::User].iter().copied() + } } #[derive(Debug)] |
