Added missing arguments error whenever we try to run an recipe with
arguments, since arguments are unsupported.
This commit is contained in:
parent
d5f81dc0b4
commit
ebd4186452
1
notes
1
notes
@ -15,6 +15,7 @@ notes
|
||||
- allow exporting environment variables
|
||||
- write some tests to test the binary itself and all command line flags
|
||||
- remove unhandled token stuff
|
||||
- test that run runs first recipe by default
|
||||
- parse arguments on command line:
|
||||
. ugly but conservative: j build --set a=hello
|
||||
. by export: A=HELLO j build
|
||||
|
@ -585,6 +585,11 @@ impl<'a> Justfile<'a> {
|
||||
}
|
||||
let recipes = names.iter().map(|name| self.recipes.get(name).unwrap()).collect::<Vec<_>>();
|
||||
let mut ran = HashSet::new();
|
||||
for recipe in &recipes {
|
||||
if !recipe.arguments.is_empty() {
|
||||
return Err(RunError::MissingArguments);
|
||||
}
|
||||
}
|
||||
for recipe in recipes {
|
||||
try!(self.run_recipe(recipe, &mut ran));
|
||||
}
|
||||
@ -620,6 +625,7 @@ impl<'a> Display for Justfile<'a> {
|
||||
#[derive(Debug)]
|
||||
enum RunError<'a> {
|
||||
UnknownRecipes{recipes: Vec<&'a str>},
|
||||
MissingArguments,
|
||||
Signal{recipe: &'a str, signal: i32},
|
||||
Code{recipe: &'a str, code: i32},
|
||||
UnknownFailure{recipe: &'a str},
|
||||
@ -637,6 +643,9 @@ impl<'a> Display for RunError<'a> {
|
||||
try!(write!(f, "Justfile does not contain recipes: {}", recipes.join(" ")));
|
||||
};
|
||||
},
|
||||
RunError::MissingArguments => {
|
||||
try!(write!(f, "Running recipes with arguments is not yet supported"));
|
||||
},
|
||||
RunError::Code{recipe, code} => {
|
||||
try!(write!(f, "Recipe \"{}\" failed with code {}", recipe, code));
|
||||
},
|
||||
|
10
src/tests.rs
10
src/tests.rs
@ -601,6 +601,16 @@ c: b
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_arguments_not_supported() {
|
||||
let text = "a foo:";
|
||||
match parse_success(text).run(&["a"]) {
|
||||
Err(super::RunError::MissingArguments) => {}
|
||||
result => panic!("Expecting MissingArguments from run() but got {:?}", result),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
#[test]
|
||||
fn run_shebang() {
|
||||
|
Loading…
Reference in New Issue
Block a user