@@ -41,20 +41,20 @@ public static void Main(string[] args)
41
41
{
42
42
outputFilePath = Path . ChangeExtension ( outputFilePath , "json" ) ;
43
43
44
- bool ? result = GetBoolArgValue ( args [ 2 ] , "--add-character-details-to-full-names" ) ;
44
+ bool ? result = GetBoolArgValue ( args , "--add-character-details-to-full-names" , 2 ) ;
45
45
if ( result is not null )
46
46
{
47
47
shouldAddDefinition = result . Value ;
48
48
49
- result = GetBoolArgValue ( args [ 3 ] , "--add-details-to-one-word-full-names" ) ;
49
+ result = GetBoolArgValue ( args , "--add-details-to-one-word-full-names" , 2 ) ;
50
50
if ( result is not null )
51
51
{
52
52
addDefinitionToOneWordNames = result . Value ;
53
- result = GetBoolArgValue ( args [ 4 ] , "--add-details-to-given-names" ) ;
53
+ result = GetBoolArgValue ( args , "--add-details-to-given-names" , 2 ) ;
54
54
if ( result is not null )
55
55
{
56
56
addDefinitionToGivenNames = result . Value ;
57
- result = GetBoolArgValue ( args [ 5 ] , "--add-details-to-surnames" ) ;
57
+ result = GetBoolArgValue ( args , "--add-details-to-surnames" , 2 ) ;
58
58
if ( result is not null )
59
59
{
60
60
addDefinitionToSurnames = result . Value ;
@@ -435,26 +435,36 @@ private static bool GetAnserOfYesNoQuestion(string question)
435
435
}
436
436
}
437
437
438
- private static bool ? GetBoolArgValue ( string arg , string flagName )
438
+ private static bool ? GetBoolArgValue ( string [ ] args , string flagName , int startIndex )
439
439
{
440
- string [ ] addCharacterDetailToFullNameOption = arg . Split ( '=' , StringSplitOptions . TrimEntries | StringSplitOptions . RemoveEmptyEntries ) ;
441
- if ( addCharacterDetailToFullNameOption . Length is 2 && addCharacterDetailToFullNameOption [ 0 ] == flagName )
440
+ string [ ] ? splitOptionParts = null ;
441
+ for ( int i = startIndex ; i < args . Length ; i ++ )
442
442
{
443
- if ( string . Equals ( addCharacterDetailToFullNameOption [ 1 ] , "true" , StringComparison . OrdinalIgnoreCase ) )
443
+ string [ ] tempOption = args [ i ] . Split ( '=' , StringSplitOptions . TrimEntries | StringSplitOptions . RemoveEmptyEntries ) ;
444
+ if ( tempOption . Length is 2 && tempOption [ 0 ] == flagName )
444
445
{
445
- return true ;
446
- }
447
-
448
- if ( string . Equals ( addCharacterDetailToFullNameOption [ 1 ] , "false" , StringComparison . OrdinalIgnoreCase ) )
449
- {
450
- return false ;
446
+ splitOptionParts = tempOption ;
447
+ break ;
451
448
}
449
+ }
452
450
453
- Console . WriteLine ( $ "Invalid value for '{ flagName } ' option!") ;
451
+ if ( splitOptionParts is null )
452
+ {
453
+ Console . WriteLine ( "Invalid input!" ) ;
454
454
return null ;
455
455
}
456
456
457
- Console . WriteLine ( "Invalid input!" ) ;
457
+ if ( string . Equals ( splitOptionParts [ 1 ] , "true" , StringComparison . OrdinalIgnoreCase ) || string . Equals ( splitOptionParts [ 1 ] , "t" , StringComparison . OrdinalIgnoreCase ) )
458
+ {
459
+ return true ;
460
+ }
461
+
462
+ if ( string . Equals ( splitOptionParts [ 1 ] , "false" , StringComparison . OrdinalIgnoreCase ) || string . Equals ( splitOptionParts [ 1 ] , "f" , StringComparison . OrdinalIgnoreCase ) )
463
+ {
464
+ return false ;
465
+ }
466
+
467
+ Console . WriteLine ( $ "Invalid value for '{ flagName } ' option!") ;
458
468
return null ;
459
469
}
460
470
0 commit comments