@@ -525,11 +525,12 @@ impl CommandOptions {
525525 I : Iterator < Item = T > ,
526526 T : Into < OsString > + Clone ,
527527 {
528- let arg = match args. next ( ) { Some ( arg) => {
529- arg. into ( )
530- } _ => {
531- return Ok ( None ) ;
532- } } ;
528+ let arg = match args. next ( ) {
529+ Some ( arg) => arg. into ( ) ,
530+ _ => {
531+ return Ok ( None ) ;
532+ }
533+ } ;
533534
534535 // TODO expand response files, which have form `@path`.
535536 // Response files content is treated as regular command line parameters.
@@ -571,38 +572,44 @@ impl CommandOptions {
571572 // Separate takes value from next argument.
572573 OptionKind :: Separate => {
573574 if definition. matches_exact ( & arg) {
574- match args. next ( ) { Some ( value) => {
575- let value = value. into ( ) ;
576-
577- return Ok ( Some ( ParsedArgument :: SingleValue (
578- definition. clone ( ) ,
579- value,
580- ) ) ) ;
581- } _ => {
582- return Err ( Error :: ParseNoArgumentValue (
583- definition. option_name . clone ( ) ,
584- ) ) ;
585- } }
586- }
587- }
588- // Takes form `-name value` or `-namevalue`. e.g. `-l`.
589- OptionKind :: JoinedOrSeparate => {
590- if let Some ( remaining) = definition. matches_prefix ( & arg) {
591- // Empty remaining means we consumed the full argument and the
592- // value is the next argument.
593- if remaining. is_empty ( ) {
594- match args. next ( ) { Some ( value) => {
575+ match args. next ( ) {
576+ Some ( value) => {
595577 let value = value. into ( ) ;
596578
597579 return Ok ( Some ( ParsedArgument :: SingleValue (
598580 definition. clone ( ) ,
599581 value,
600582 ) ) ) ;
601- } _ => {
583+ }
584+ _ => {
602585 return Err ( Error :: ParseNoArgumentValue (
603586 definition. option_name . clone ( ) ,
604587 ) ) ;
605- } }
588+ }
589+ }
590+ }
591+ }
592+ // Takes form `-name value` or `-namevalue`. e.g. `-l`.
593+ OptionKind :: JoinedOrSeparate => {
594+ if let Some ( remaining) = definition. matches_prefix ( & arg) {
595+ // Empty remaining means we consumed the full argument and the
596+ // value is the next argument.
597+ if remaining. is_empty ( ) {
598+ match args. next ( ) {
599+ Some ( value) => {
600+ let value = value. into ( ) ;
601+
602+ return Ok ( Some ( ParsedArgument :: SingleValue (
603+ definition. clone ( ) ,
604+ value,
605+ ) ) ) ;
606+ }
607+ _ => {
608+ return Err ( Error :: ParseNoArgumentValue (
609+ definition. option_name . clone ( ) ,
610+ ) ) ;
611+ }
612+ }
606613 } else {
607614 return Ok ( Some ( ParsedArgument :: SingleValue (
608615 definition. clone ( ) ,
@@ -615,19 +622,22 @@ impl CommandOptions {
615622 // Takes form `-name=<key> value`.
616623 OptionKind :: JoinedAndSeparate => {
617624 if let Some ( remaining) = definition. matches_prefix ( & arg) {
618- match args. next ( ) { Some ( value) => {
619- let value = value. into ( ) ;
625+ match args. next ( ) {
626+ Some ( value) => {
627+ let value = value. into ( ) ;
620628
621- return Ok ( Some ( ParsedArgument :: SingleValueKeyed (
622- definition. clone ( ) ,
623- remaining. to_os_string ( ) ,
624- value,
625- ) ) ) ;
626- } _ => {
627- return Err ( Error :: ParseNoArgumentValue (
628- definition. option_name . clone ( ) ,
629- ) ) ;
630- } }
629+ return Ok ( Some ( ParsedArgument :: SingleValueKeyed (
630+ definition. clone ( ) ,
631+ remaining. to_os_string ( ) ,
632+ value,
633+ ) ) ) ;
634+ }
635+ _ => {
636+ return Err ( Error :: ParseNoArgumentValue (
637+ definition. option_name . clone ( ) ,
638+ ) ) ;
639+ }
640+ }
631641 }
632642 }
633643
@@ -807,14 +817,13 @@ impl ParsedArguments {
807817 match options
808818 . iter_options ( )
809819 . find ( |candidate| & candidate. option_name == alias)
810- { Some ( canonical) => {
811- Ok ( arg. with_option ( canonical. clone ( ) ) )
812- } _ => {
813- Err ( Error :: AliasMissing (
820+ {
821+ Some ( canonical) => Ok ( arg. with_option ( canonical. clone ( ) ) ) ,
822+ _ => Err ( Error :: AliasMissing (
814823 option. option_name . clone ( ) ,
815824 alias. to_string ( ) ,
816- ) )
817- } }
825+ ) ) ,
826+ }
818827 } else {
819828 Ok ( arg)
820829 }
0 commit comments