src/tools.rs: new helper required_array_param()

This commit is contained in:
Dietmar Maurer 2019-02-26 08:48:17 +01:00
parent aaba6faace
commit f8dfbb45c0

View File

@ -330,6 +330,13 @@ pub fn required_integer_param<'a>(param: &'a Value, name: &str) -> Result<i64, E
}
}
pub fn required_array_param<'a>(param: &'a Value, name: &str) -> Result<Vec<Value>, Error> {
match param[name].as_array() {
Some(s) => Ok(s.to_vec()),
None => bail!("missing parameter '{}'", name),
}
}
pub fn complete_file_name(arg: &str) -> Vec<String> {
let mut result = vec![];