@@ -14,7 +14,6 @@ namespace McMaster.Extensions.CommandLineUtils
1414 internal sealed class CommandLineProcessor
1515 {
1616 private readonly CommandLineApplication _initialCommand ;
17- private readonly ParserConfig _config ;
1817 private readonly ArgumentEnumerator _enumerator ;
1918
2019 private CommandLineApplication _currentCommand
@@ -31,12 +30,10 @@ private CommandLineApplication _currentCommand
3130
3231 public CommandLineProcessor (
3332 CommandLineApplication command ,
34- ParserConfig config ,
3533 IReadOnlyList < string > arguments )
3634 {
3735 _initialCommand = command ;
38- _config = config ?? throw new ArgumentNullException ( nameof ( config ) ) ;
39- _enumerator = new ArgumentEnumerator ( command , _config , arguments ?? new string [ 0 ] ) ;
36+ _enumerator = new ArgumentEnumerator ( command , arguments ?? new string [ 0 ] ) ;
4037 CheckForShortOptionClustering ( command ) ;
4138 }
4239
@@ -260,7 +257,7 @@ private bool ProcessOption(OptionArgument arg)
260257 }
261258 else
262259 {
263- if ( _config . OptionNameAndValueCanBeSpaceSeparated )
260+ if ( _currentCommand . OptionNameAndValueCanBeSpaceSeparated )
264261 {
265262 if ( _enumerator . MoveNext ( ) )
266263 {
@@ -334,7 +331,7 @@ private bool ProcessArgumentSeparator()
334331
335332 private bool ProcessUnexpectedArg ( string argTypeName , string ? argValue = null )
336333 {
337- switch ( _config . UnrecognizedArgumentHandling )
334+ switch ( _currentCommand . UnrecognizedArgumentHandling )
338335 {
339336 case UnrecognizedArgumentHandling . Throw :
340337 _currentCommand . ShowHint ( ) ;
@@ -429,11 +426,9 @@ private sealed class ArgumentEnumerator : IEnumerator<Argument?>
429426 {
430427 private readonly IEnumerator < string > _rawArgEnumerator ;
431428 private IEnumerator < string > ? _rspEnumerator ;
432- private readonly ParserConfig _config ;
433429
434- public ArgumentEnumerator ( CommandLineApplication command , ParserConfig config , IReadOnlyList < string > rawArguments )
430+ public ArgumentEnumerator ( CommandLineApplication command , IReadOnlyList < string > rawArguments )
435431 {
436- _config = config ;
437432 CurrentCommand = command ;
438433 _rawArgEnumerator = rawArguments . GetEnumerator ( ) ;
439434 }
@@ -489,15 +484,15 @@ private Argument CreateArgument(string raw)
489484
490485 if ( raw [ 1 ] != '-' )
491486 {
492- return new OptionArgument ( raw , _config . OptionNameValueSeparators , isShortOption : true ) ;
487+ return new OptionArgument ( raw , CurrentCommand . OptionNameValueSeparators , isShortOption : true ) ;
493488 }
494489
495490 if ( raw . Length == 2 )
496491 {
497492 return ArgumentSeparatorArgument . Instance ;
498493 }
499494
500- return new OptionArgument ( raw , _config . OptionNameValueSeparators , isShortOption : false ) ;
495+ return new OptionArgument ( raw , CurrentCommand . OptionNameValueSeparators , isShortOption : false ) ;
501496 }
502497
503498 private IEnumerator < string > CreateRspParser ( string path )
0 commit comments