@@ -14,64 +14,70 @@ public static Settings ParseArguments(string[] args)
1414 {
1515 var settings = new Settings ( ) ;
1616 int argIndex = 0 ;
17-
17+
1818 while ( argIndex < args . Length )
1919 {
2020 switch ( args [ argIndex ] )
2121 {
2222 case "-help" :
2323 settings . Help = true ;
24- argIndex ++ ;
2524 break ;
2625 case "-verbose" :
2726 settings . Verbose = true ;
28- argIndex ++ ;
2927 break ;
3028 case "-d" :
31- if ( argIndex + 1 < args . Length )
32- {
33- settings . DirectoryPath = args [ argIndex + 1 ] ;
34- argIndex += 2 ;
35- }
36- else
37- {
38- argIndex ++ ;
39- }
29+ HandleDirectory ( args , settings , ref argIndex ) ;
4030 break ;
4131 case "-format" :
42- if ( argIndex + 1 < args . Length )
43- {
44- string formatString = args [ argIndex + 1 ] ;
45- argIndex += 2 ;
46- if ( Enum . TryParse < ExportFormat > ( formatString , true , out ExportFormat result ) )
47- {
48- settings . Format = result ;
49- }
50- else
51- {
52- Console . WriteLine ( $ "Invalid format: { formatString } . Valid formats are: { string . Join ( ", " , Enum . GetNames < ExportFormat > ( ) ) } . Using default format { settings . Format } ") ;
53- }
54- }
32+ HandleFormat ( args , settings , ref argIndex ) ;
5533 break ;
5634 case "-output" :
57- if ( argIndex + 1 < args . Length )
58- {
59- settings . OutputPath = args [ argIndex + 1 ] ;
60- argIndex += 2 ;
61- }
62- else
63- {
64- argIndex ++ ;
65- }
35+ HandleOutput ( args , settings , ref argIndex ) ;
6636 break ;
6737 default :
68- argIndex ++ ;
6938 break ;
7039 }
40+ argIndex ++ ;
7141 }
7242 return settings ;
7343 }
7444
45+ private static void HandleDirectory ( string [ ] args , Settings settings , ref int argIndex )
46+ {
47+ if ( argIndex + 1 < args . Length )
48+ {
49+ settings . DirectoryPath = args [ argIndex + 1 ] ;
50+ argIndex ++ ;
51+ }
52+
53+ }
54+
55+ private static void HandleFormat ( string [ ] args , Settings settings , ref int argIndex )
56+ {
57+ if ( argIndex + 1 < args . Length )
58+ {
59+ string formatString = args [ argIndex + 1 ] ;
60+ argIndex ++ ;
61+ if ( Enum . TryParse < ExportFormat > ( formatString , true , out ExportFormat result ) )
62+ {
63+ settings . Format = result ;
64+ }
65+ else
66+ {
67+ Console . WriteLine ( $ "Invalid format: { formatString } . Valid formats are: { string . Join ( ", " , Enum . GetNames < ExportFormat > ( ) ) } . Using default format { settings . Format } ") ;
68+ }
69+ }
70+ }
71+
72+ private static void HandleOutput ( string [ ] args , Settings settings , ref int argIndex )
73+ {
74+ if ( argIndex + 1 < args . Length )
75+ {
76+ settings . OutputPath = args [ argIndex + 1 ] ;
77+ argIndex ++ ;
78+ }
79+ }
80+
7581 /// <summary>
7682 /// Gets a valid user selection from the available solutions.
7783 /// </summary>
@@ -153,9 +159,9 @@ public static string GetExportFileNameWithExtension(string filePath, CoreUtils.E
153159 }
154160
155161 // If an output directory is specified, combine the path
156- return outputPath != null
162+ return outputPath != null
157163 ? Path . Combine ( Path . GetFullPath ( outputPath ) , fileName )
158164 : Path . Combine ( Path . GetDirectoryName ( filePath ) ?? Path . GetFullPath ( "." ) , fileName ) ;
159- }
165+ }
160166 }
161167}
0 commit comments