@@ -372,9 +372,9 @@ pub fn opt_count(mm: &Matches, nm: &str) -> uint {
372
372
pub fn opts_present ( mm : & Matches , names : & [ ~str ] ) -> bool {
373
373
for vec:: each( names) |nm| {
374
374
match find_opt ( mm. opts , mkname ( * nm) ) {
375
- Some ( _ ) => return true ,
376
- None => ( )
377
- }
375
+ Some ( id ) if !mm . vals [ id ] . is_empty ( ) => return true ,
376
+ _ => ( ) ,
377
+ } ;
378
378
}
379
379
false
380
380
}
@@ -1177,7 +1177,7 @@ mod tests {
1177
1177
#[test]
1178
1178
pub fn test_multi() {
1179
1179
let args = ~[~" -e", ~" foo", ~" --encrypt", ~" foo"];
1180
- let opts = ~[optopt(~" e"), optopt(~" encrypt")];
1180
+ let opts = ~[optopt(~" e"), optopt(~" encrypt"), optopt(~" f ") ];
1181
1181
let matches = &match getopts(args, opts) {
1182
1182
result::Ok(m) => m,
1183
1183
result::Err(_) => fail!()
@@ -1186,6 +1186,7 @@ mod tests {
1186
1186
fail_unless!(opts_present(matches, ~[~" encrypt"]));
1187
1187
fail_unless!(opts_present(matches, ~[~" encrypt", ~" e"]));
1188
1188
fail_unless!(opts_present(matches, ~[~" e", ~" encrypt"]));
1189
+ fail_unless!(!opts_present(matches, ~[~" f"]));
1189
1190
fail_unless!(!opts_present(matches, ~[~" thing"]));
1190
1191
fail_unless!(!opts_present(matches, ~[]));
1191
1192
0 commit comments