Skip to content

Commit

Permalink
Show available profiles on error
Browse files Browse the repository at this point in the history
  • Loading branch information
alarsyo committed Oct 6, 2020
1 parent d3d3397 commit 3afc004
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/bootstrap/flags.rs
Expand Up @@ -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())
};
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/setup.rs
Expand Up @@ -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)]
Expand Down

0 comments on commit 3afc004

Please sign in to comment.