@@ -21,6 +21,7 @@ public static ParserResult<object> Choose(
2121 CultureInfo parsingCulture ,
2222 bool autoHelp ,
2323 bool autoVersion ,
24+ OptionsParseMode optionsParseMode ,
2425 IEnumerable < ErrorType > nonFatalErrors )
2526 {
2627 return Choose (
@@ -33,6 +34,7 @@ public static ParserResult<object> Choose(
3334 autoHelp ,
3435 autoVersion ,
3536 false ,
37+ optionsParseMode ,
3638 nonFatalErrors ) ;
3739 }
3840
@@ -46,6 +48,7 @@ public static ParserResult<object> Choose(
4648 bool autoHelp ,
4749 bool autoVersion ,
4850 bool allowMultiInstance ,
51+ OptionsParseMode optionsParseMode ,
4952 IEnumerable < ErrorType > nonFatalErrors )
5053 {
5154 var verbs = Verb . SelectFromTypes ( types ) ;
@@ -62,22 +65,23 @@ ParserResult<object> choose()
6265 var firstArg = arguments . First ( ) ;
6366
6467 bool preprocCompare ( string command ) =>
65- nameComparer . Equals ( command , firstArg ) ||
66- nameComparer . Equals ( string . Concat ( "--" , command ) , firstArg ) ;
68+ nameComparer . Equals ( command , firstArg )
69+ || optionsParseMode != OptionsParseMode . SingleDashOnly && nameComparer . Equals ( string . Concat ( "--" , command ) , firstArg )
70+ || optionsParseMode != OptionsParseMode . Default && nameComparer . Equals ( string . Concat ( "-" , command ) , firstArg ) ;
6771
6872 return ( autoHelp && preprocCompare ( "help" ) )
6973 ? MakeNotParsed ( types ,
7074 MakeHelpVerbRequestedError ( verbs ,
7175 arguments . Skip ( 1 ) . FirstOrDefault ( ) ?? string . Empty , nameComparer ) )
7276 : ( autoVersion && preprocCompare ( "version" ) )
7377 ? MakeNotParsed ( types , new VersionRequestedError ( ) )
74- : MatchVerb ( tokenizer , verbs , defaultVerb , arguments , nameComparer , ignoreValueCase , parsingCulture , autoHelp , autoVersion , allowMultiInstance , nonFatalErrors ) ;
78+ : MatchVerb ( tokenizer , verbs , defaultVerb , arguments , nameComparer , ignoreValueCase , parsingCulture , autoHelp , autoVersion , allowMultiInstance , optionsParseMode , nonFatalErrors ) ;
7579 }
7680
7781 return arguments . Any ( )
7882 ? choose ( )
7983 : ( defaultVerbCount == 1
80- ? MatchDefaultVerb ( tokenizer , verbs , defaultVerb , arguments , nameComparer , ignoreValueCase , parsingCulture , autoHelp , autoVersion , nonFatalErrors )
84+ ? MatchDefaultVerb ( tokenizer , verbs , defaultVerb , arguments , nameComparer , ignoreValueCase , parsingCulture , autoHelp , autoVersion , optionsParseMode , nonFatalErrors )
8185 : MakeNotParsed ( types , new NoVerbSelectedError ( ) ) ) ;
8286 }
8387
@@ -91,6 +95,7 @@ private static ParserResult<object> MatchDefaultVerb(
9195 CultureInfo parsingCulture ,
9296 bool autoHelp ,
9397 bool autoVersion ,
98+ OptionsParseMode optionsParseMode ,
9499 IEnumerable < ErrorType > nonFatalErrors )
95100 {
96101 return ! ( defaultVerb is null )
@@ -103,6 +108,7 @@ private static ParserResult<object> MatchDefaultVerb(
103108 parsingCulture ,
104109 autoHelp ,
105110 autoVersion ,
111+ optionsParseMode ,
106112 nonFatalErrors )
107113 : MakeNotParsed ( verbs . Select ( v => v . Item2 ) , new BadVerbSelectedError ( arguments . First ( ) ) ) ;
108114 }
@@ -118,6 +124,7 @@ private static ParserResult<object> MatchVerb(
118124 bool autoHelp ,
119125 bool autoVersion ,
120126 bool allowMultiInstance ,
127+ OptionsParseMode optionsParseMode ,
121128 IEnumerable < ErrorType > nonFatalErrors )
122129 {
123130 string firstArg = arguments . First ( ) ;
@@ -129,7 +136,7 @@ private static ParserResult<object> MatchVerb(
129136
130137 if ( verbUsed == default )
131138 {
132- return MatchDefaultVerb ( tokenizer , verbs , defaultVerb , arguments , nameComparer , ignoreValueCase , parsingCulture , autoHelp , autoVersion , nonFatalErrors ) ;
139+ return MatchDefaultVerb ( tokenizer , verbs , defaultVerb , arguments , nameComparer , ignoreValueCase , parsingCulture , autoHelp , autoVersion , optionsParseMode , nonFatalErrors ) ;
133140 }
134141 return InstanceBuilder . Build (
135142 Maybe . Just < Func < object > > (
@@ -141,7 +148,8 @@ private static ParserResult<object> MatchVerb(
141148 parsingCulture ,
142149 autoHelp ,
143150 autoVersion ,
144- allowMultiInstance ,
151+ allowMultiInstance ,
152+ optionsParseMode ,
145153 nonFatalErrors ) ;
146154 }
147155
0 commit comments