@@ -9,13 +9,49 @@ namespace UnityBuilderAction.Input
99{ 
1010    public  class  ArgumentsParser 
1111    { 
12-         static string  EOL  =  Environment . NewLine ; 
12+         static string  Eol  =  Environment . NewLine ; 
1313        static readonly  string [ ]  Secrets  =  {  "androidKeystorePass" ,  "androidKeyaliasName" ,  "androidKeyaliasPass"  } ; 
14- 
14+         const  string  DefaultCustomBuildName  =  "TestBuild" ; 
15+         
1516        public  static Dictionary < string ,  string >  GetValidatedOptions ( ) 
1617        { 
17-             Dictionary < string ,  string >  validatedOptions ; 
18-             ParseCommandLineArguments ( out  validatedOptions ) ; 
18+             ParseCommandLineArguments ( out  var  validatedOptions ) ; 
19+             
20+             if  ( ! validatedOptions . TryGetValue ( "projectPath" ,  out  string  _ ) ) 
21+             { 
22+                 Console . WriteLine ( "Missing argument -projectPath" ) ; 
23+                 EditorApplication . Exit ( 110 ) ; 
24+             } 
25+ 
26+             if  ( ! validatedOptions . TryGetValue ( "buildTarget" ,  out  string  buildTarget ) ) 
27+             { 
28+                 Console . WriteLine ( "Missing argument -buildTarget" ) ; 
29+                 EditorApplication . Exit ( 120 ) ; 
30+             } 
31+ 
32+             if  ( ! Enum . IsDefined ( typeof ( BuildTarget ) ,  buildTarget  ??  string . Empty ) ) 
33+             { 
34+                 Console . WriteLine ( $ "{ buildTarget }  is not a defined { nameof ( BuildTarget ) } ") ; 
35+                 EditorApplication . Exit ( 121 ) ; 
36+             } 
37+ 
38+             if  ( ! validatedOptions . TryGetValue ( "customBuildPath" ,  out  string  _ ) ) 
39+             { 
40+                 Console . WriteLine ( "Missing argument -customBuildPath" ) ; 
41+                 EditorApplication . Exit ( 130 ) ; 
42+             } 
43+             
44+             if  ( ! validatedOptions . TryGetValue ( "customBuildName" ,  out  string  customBuildName ) ) 
45+             { 
46+                 Console . WriteLine ( $ "Missing argument -customBuildName, defaulting to { defaultCustomBuildName } .") ; 
47+                 validatedOptions . Add ( "customBuildName" ,  DefaultCustomBuildName ) ; 
48+             } 
49+             else  if  ( customBuildName  ==  "" ) 
50+             { 
51+                 Console . WriteLine ( $ "Invalid argument -customBuildName, defaulting to { defaultCustomBuildName } .") ; 
52+                 validatedOptions . Add ( "customBuildName" ,  DefaultCustomBuildName ) ; 
53+             } 
54+             
1955            return  validatedOptions ; 
2056        } 
2157
@@ -25,15 +61,16 @@ static void ParseCommandLineArguments(out Dictionary<string, string> providedArg
2561            string [ ]  args  =  Environment . GetCommandLineArgs ( ) ; 
2662
2763            Console . WriteLine ( 
28-                 EOL  + 
29-                 "###########################"    +   EOL  + 
30-                 "#    Parsing settings     #"    +   EOL  + 
31-                 "###########################"    +   EOL  + 
32-                 EOL 
64+                 $ " { Eol } " + 
65+                 $ "###########################{ Eol } " + 
66+                 $ "#    Parsing settings     #{ Eol } " + 
67+                 $ "###########################{ Eol } " + 
68+                 $ " { Eol } " 
3369            ) ; 
3470
3571            // Extract flags with optional values 
36-             for  ( int  current  =  0 ,  next  =  1 ;  current  <  args . Length ;  current ++ ,  next ++ )  { 
72+             for  ( int  current  =  0 ,  next  =  1 ;  current  <  args . Length ;  current ++ ,  next ++ ) 
73+             { 
3774                // Parse flag 
3875                bool  isFlag  =  args [ current ] . StartsWith ( "-" ) ; 
3976                if  ( ! isFlag )  continue ; 
@@ -46,7 +83,7 @@ static void ParseCommandLineArguments(out Dictionary<string, string> providedArg
4683                string  displayValue  =  secret  ?  "*HIDDEN*"  :  "\" "  +  value  +  "\" " ; 
4784
4885                // Assign 
49-                 Console . WriteLine ( "Found flag \" "    +   flag   +   " \"  with value "   +   displayValue ) ; 
86+                 Console . WriteLine ( $ "Found flag \" { flag } \"  with value { displayValue } ." ) ; 
5087                providedArguments . Add ( flag ,  value ) ; 
5188            } 
5289        } 
0 commit comments