mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Merge pull request #265 from taskchampion/issue264
Treat partially-matched arguments as an error
This commit is contained in:
commit
4ccd33bc0c
1 changed files with 11 additions and 2 deletions
|
@ -14,8 +14,12 @@ where
|
|||
if let Some(arg) = input.get(0) {
|
||||
return match f(arg) {
|
||||
Ok(("", rv)) => Ok((&input[1..], rv)),
|
||||
// single-arg parsers must consume the entire arg
|
||||
Ok((unconsumed, _)) => panic!("unconsumed argument input {}", unconsumed),
|
||||
// single-arg parsers must consume the entire arg, so consider unconsumed
|
||||
// output to be an error.
|
||||
Ok((_, _)) => Err(Err::Error(Error {
|
||||
input,
|
||||
code: ErrorKind::Eof,
|
||||
})),
|
||||
// single-arg parsers are all complete parsers
|
||||
Err(Err::Incomplete(_)) => unreachable!(),
|
||||
// for error and failure, rewrite to an error at this position in the arugment list
|
||||
|
@ -48,4 +52,9 @@ mod test {
|
|||
);
|
||||
assert!(arg_matching(plus_tag)(argv!["foo", "bar"]).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_partial_arg_matching() {
|
||||
assert!(arg_matching(wait_colon)(argv!["wait:UNRECOGNIZED"]).is_err());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue