File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -329,7 +329,7 @@ impl FlagSet {
329
329
330
330
let mut av = args
331
331
. into_iter ( )
332
- . flat_map ( |arg| arg. chars ( ) . chain ( " " . chars ( ) ) )
332
+ . flat_map ( |arg| arg. trim_matches ( ' ' ) . chars ( ) . chain ( " " . chars ( ) ) )
333
333
. peekable ( ) ;
334
334
335
335
loop {
@@ -344,7 +344,7 @@ impl FlagSet {
344
344
'-' => {
345
345
av. next ( ) ;
346
346
let arg = av. peek ( ) ;
347
- if arg. is_none ( ) {
347
+ if arg. is_none ( ) || * arg . unwrap ( ) == ' ' {
348
348
av. next ( ) ;
349
349
self . args . push ( "-" . to_string ( ) ) ;
350
350
return Ok ( ( ) ) ;
@@ -974,6 +974,19 @@ mod tests {
974
974
assert_eq ! ( args[ 1 ] , "world" ) ;
975
975
}
976
976
977
+ #[ test]
978
+ fn parse_single_dash_stdin ( ) {
979
+ let mut flags = FlagSet :: new ( "test" ) ;
980
+
981
+ if let Err ( err) = flags. parse ( vec ! [ "-" ] ) {
982
+ panic ! ( err) ;
983
+ }
984
+
985
+ let args = flags. args ( ) ;
986
+ assert_eq ! ( args. len( ) , 1 ) ;
987
+ assert_eq ! ( args[ 0 ] , "-" ) ;
988
+ }
989
+
977
990
#[ test]
978
991
fn parse_terminate_flags ( ) {
979
992
let mut flags = FlagSet :: new ( "test" ) ;
You can’t perform that action at this time.
0 commit comments