@@ -29,6 +29,24 @@ public override void OnConfigure(ICommandConfigurationBuilder<object> builder)
2929 }
3030 }
3131
32+ [ Theory ]
33+ [ InlineData ( true ) ]
34+ [ InlineData ( false ) ]
35+ public void CommandLineParserParsesCorrectOptionsWithPostfix ( bool useShort )
36+ {
37+ var query = $ "{ ( useShort ? "-" : "--" ) } p=some text";
38+
39+ var parser = new CommandLineParser < AddOption > ( ) ;
40+
41+ parser . Configure ( p => p . Message ) . Name ( "p" , "p" ) . Required ( ) ;
42+
43+ var result = parser . Parse ( new string [ ] { query } ) ;
44+
45+ result . AssertNoErrors ( ) ;
46+
47+ Assert . Equal ( "some text" , result . Result . Message ) ;
48+ }
49+
3250 [ Fact ]
3351 public void CommandLineParserUsesCorrectOptions ( )
3452 {
@@ -174,7 +192,7 @@ public void ParseTests()
174192
175193 [ Theory ]
176194 [ InlineData ( new [ ] { "app.exe" , "-e" , "Opt1" } , false , EnumOption . Opt1 ) ]
177- [ InlineData ( new [ ] { "app.exe" , "-e" , " opt1" } , false , EnumOption . Opt1 ) ]
195+ [ InlineData ( new [ ] { "app.exe" , "-e= opt1" } , false , EnumOption . Opt1 ) ]
178196 [ InlineData ( new [ ] { "app.exe" , "-e" , "Opt2" } , false , EnumOption . Opt2 ) ]
179197 [ InlineData ( new [ ] { "app.exe" , "-e" , "bla" } , true , default ( EnumOption ) ) ]
180198 [ InlineData ( new [ ] { "app.exe" , "-e" } , true , default ( EnumOption ) ) ]
@@ -195,11 +213,11 @@ public void ParseEnumInArguments(string[] args, bool hasErrors, EnumOption enumO
195213
196214 [ Theory ]
197215 // string
198- [ InlineData ( typeof ( string ) , new [ ] { "-1" , " message1", "-2" , "-3" } , "default" , "message1" , "default" , "default" ) ]
216+ [ InlineData ( typeof ( string ) , new [ ] { "-1= message1" , "-2" , "-3" } , "default" , "message1" , "default" , "default" ) ]
199217 [ InlineData ( typeof ( string ) , new [ ] { "-1" , "-2" , "message2" , "-3" } , "default" , "default" , "message2" , "default" ) ]
200218 [ InlineData ( typeof ( string ) , new [ ] { "-1" , "-2" , "-3" } , "default" , "default" , "default" , "default" ) ]
201219 // bool
202- [ InlineData ( typeof ( bool ) , new [ ] { "-1" , " false", "-2" , "-3" } , false , false , true , true ) ]
220+ [ InlineData ( typeof ( bool ) , new [ ] { "-1= false" , "-2" , "-3" } , false , false , true , true ) ]
203221 [ InlineData ( typeof ( bool ) , new [ ] { "-1" , "-2" , "false" , "-3" } , false , true , false , true ) ]
204222 [ InlineData ( typeof ( bool ) , new [ ] { "-1" , "-2" , "-3" } , false , true , true , true ) ]
205223 //// int
@@ -316,7 +334,7 @@ public void ParseWithCommandTests()
316334 . Name ( "m" , "message" )
317335 . Required ( ) ;
318336
319- var parsed = parser . Parse ( new string [ ] { "app.exe" , "-o" , "test" , "add" , "-m" , " my message" } ) ;
337+ var parsed = parser . Parse ( new string [ ] { "app.exe" , "-o" , "test" , "add" , "-m= my message" } ) ;
320338
321339 parsed . AssertNoErrors ( ) ;
322340
0 commit comments