Use new functions in which (#3310)

* Use new functions in which

* Impl rest_with_minimum and use it

* Use has_flag instead of get_switch
This commit is contained in:
Leonhard Kipp
2021-04-20 08:38:36 +02:00
committed by GitHub
parent 0fc9b6cfa2
commit 1a46e70dfb
2 changed files with 27 additions and 18 deletions

View File

@ -281,4 +281,18 @@ impl EvaluatedCommandArgs {
Ok(output)
}
pub fn rest_with_minimum<T: FromValue>(
&self,
pos: usize,
count: usize,
) -> Result<Vec<T>, ShellError> {
let mut output = vec![];
for i in pos..pos + count {
output.push(self.req(i)?);
}
output.extend(self.rest(pos + count)?);
Ok(output)
}
}