1- using System . Collections ;
2- using System . Reflection ;
3- using CommandLine ;
1+ using System . Reflection ;
42using GameFrameX . Foundation . Extensions ;
53using GameFrameX . Foundation . Logger ;
4+ using GameFrameX . Foundation . Options ;
65using GameFrameX . StartUp . Abstractions ;
76using GameFrameX . StartUp . Options ;
87using GameFrameX . Utility ;
@@ -28,40 +27,16 @@ public static class GameApp
2827 /// <param name="logConfiguration">初始化日志系统之前回调,可以重写参数</param>
2928 public static async Task Entry ( string [ ] args , Action initAction , Action < LogOptions > logConfiguration = null )
3029 {
31- var environmentVariablesList = new List < string > ( args ) ;
32- LogHelper . Console ( "启动参数:" + string . Join ( " " , args ) ) ;
33- LogHelper . Console ( "当前环境变量START---------------------" ) ;
34- var environmentVariables = Environment . GetEnvironmentVariables ( ) ;
35- foreach ( DictionaryEntry environmentVariable in environmentVariables )
30+ LauncherOptions launcherOptions = null ;
31+ try
3632 {
37- if ( environmentVariable . Value == null || environmentVariable . Key . ToString ( ) . IsNullOrWhiteSpace ( ) )
38- {
39- continue ;
40- }
41-
42- var key = environmentVariable . Key . ToString ( ) . StartsWith ( "--" ) ? environmentVariable . Key . ToString ( ) : "--" + environmentVariable . Key ;
43- if ( environmentVariablesList . Contains ( key ) )
44- {
45- continue ;
46- }
47-
48- environmentVariablesList . Add ( key ) ;
49- environmentVariablesList . Add ( environmentVariable . Value . ToString ( ) ) ;
33+ launcherOptions = OptionsBuilder . CreateWithDebug < LauncherOptions > ( args ) ;
5034 }
51-
52- LogHelper . Console ( string . Join ( "\n " , environmentVariablesList ) ) ;
53- LogHelper . Console ( "当前环境变量END---------------------" ) ;
54- LogHelper . Console ( string . Empty ) ;
55- LogHelper . Console ( string . Empty ) ;
56- var commandLineParser = new Parser ( configuration => { configuration . IgnoreUnknownArguments = true ; } ) ;
57-
58- var launcherOptions = commandLineParser . ParseArguments < LauncherOptions > ( environmentVariablesList ) . WithParsed ( LauncherOptionsValidate ) . WithNotParsed ( errors =>
35+ catch ( Exception e )
5936 {
60- foreach ( var error in errors )
61- {
62- LogHelper . ErrorConsole ( error . Tag + ": " + error ) ;
63- }
64- } ) ? . Value ;
37+ LogHelper . ErrorConsole ( e . Message ) ;
38+ }
39+
6540 var serverType = launcherOptions ? . ServerType ;
6641 if ( ! serverType . IsNullOrEmpty ( ) )
6742 {
0 commit comments