parent
d11e679e4b
commit
e628378dbb
15
src/app.rs
15
src/app.rs
@ -31,12 +31,12 @@ enum UseColor {
|
||||
}
|
||||
|
||||
impl UseColor {
|
||||
fn from_argument(use_color: &str) -> UseColor {
|
||||
fn from_argument(use_color: &str) -> Option<UseColor> {
|
||||
match use_color {
|
||||
"auto" => UseColor::Auto,
|
||||
"always" => UseColor::Always,
|
||||
"never" => UseColor::Never,
|
||||
_ => panic!("Invalid argument to --color. This is a bug in just."),
|
||||
"auto" => Some(UseColor::Auto),
|
||||
"always" => Some(UseColor::Always),
|
||||
"never" => Some(UseColor::Never),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,7 +140,10 @@ pub fn app() {
|
||||
.get_matches();
|
||||
|
||||
let use_color_argument = matches.value_of("color").expect("--color had no value");
|
||||
let use_color = UseColor::from_argument(use_color_argument);
|
||||
let use_color = match UseColor::from_argument(use_color_argument) {
|
||||
Some(use_color) => use_color,
|
||||
None => die!("Invalid argument to --color. This is a bug in just."),
|
||||
};
|
||||
|
||||
let justfile_option = matches.value_of("justfile");
|
||||
let working_directory_option = matches.value_of("working-directory");
|
||||
|
10
src/lib.rs
10
src/lib.rs
@ -280,12 +280,14 @@ impl<'a> Recipe<'a> {
|
||||
) -> Result<(), RunError<'a>> {
|
||||
let argument_map = self.parameters.iter().enumerate()
|
||||
.map(|(i, parameter)| if i < arguments.len() {
|
||||
(parameter.name, arguments[i])
|
||||
Ok((parameter.name, arguments[i]))
|
||||
} else if let Some(ref default) = parameter.default {
|
||||
(parameter.name, default.as_str())
|
||||
Ok((parameter.name, default.as_str()))
|
||||
} else {
|
||||
panic!("Recipe.run: missing parameter without default. This is a bug in just.");
|
||||
}).collect();
|
||||
Err(RunError::InternalError{
|
||||
message: "missing parameter without default".to_string()
|
||||
})
|
||||
}).collect::<Result<Vec<_>, _>>()?.into_iter().collect();
|
||||
|
||||
let mut evaluator = Evaluator {
|
||||
evaluated: empty(),
|
||||
|
Loading…
Reference in New Issue
Block a user