Skip to content

Commit f77a740

Browse files
committed
fixed get_option
1 parent 1528908 commit f77a740

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎src/cli.rs‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,12 @@ impl Command {
201201
/// Get the value of an option in its location
202202
pub fn get_option(&self, option_name: &str) -> Value {
203203
let args: Vec<String> = env::args().collect();
204-
205204
for (index, option) in self.options.iter().enumerate() {
206-
if args.len() <= 2 + (index) {
205+
if option.name != option_name {
206+
continue;
207+
}
208+
209+
if args.len() <= 2 + index {
207210
return Value::Missing(format!(
208211
"{} could not be found in its location ({})",
209212
option_name,
@@ -219,6 +222,8 @@ impl Command {
219222
option_name
220223
));
221224
}
225+
226+
return Value::Present(value);
222227
}
223228

224229
return Value::Missing(format!(

0 commit comments

Comments
 (0)