@@ -26,27 +26,16 @@ public class TSMU
2626 public class TSMUArgs
2727 {
2828 [ Option ( 'v' , "verbose" , FlagCounter = true , HelpText = nameof ( LocalizedString . HelpTextVerbose ) , ResourceType = typeof ( LocalizedString ) ) ]
29- public int ? Verbosity { get ; set ; }
29+ public int Verbosity { get ; set ; } = 0 ;
3030
3131 [ Option ( 'a' , "asar" , Required = true , HelpText = nameof ( LocalizedString . HelpTextAsar ) , ResourceType = typeof ( LocalizedString ) ) ]
32- public string ? AsarPath { get ; set ; }
32+ public string AsarPath { get ; set ; } = string . Empty ;
3333
3434 [ Option ( 's' , "sav" , Required = true , HelpText = nameof ( LocalizedString . HelpTextSav ) , ResourceType = typeof ( LocalizedString ) ) ]
35- public string ? SavPath { get ; set ; }
35+ public string SavPath { get ; set ; } = string . Empty ;
3636
3737 [ Option ( "dry" , HelpText = nameof ( LocalizedString . HelpTextDryRun ) , ResourceType = typeof ( LocalizedString ) ) ]
38- public bool ? DryRun { get ; set ; }
39-
40- public TSMUArgs ( )
41- {
42- // This is used to preserve the help texts for the command line arguments.
43- // It is necessary to ensure that the help texts are not trimmed by the compiler.
44- _ = LocalizedString . HelpTextVerbose ;
45- _ = LocalizedString . HelpTextAsar ;
46- _ = LocalizedString . HelpTextSav ;
47- _ = LocalizedString . HelpTextDryRun ;
48- _ = LocalizedString . HelpTextHelp ;
49- }
38+ public bool DryRun { get ; set ; } = false ;
5039 }
5140
5241 internal const string SearchTopPath = "data/scenario" ;
@@ -68,6 +57,9 @@ public TSMUArgs()
6857 [ SuppressMessage ( "Trimming" , "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code" ,
6958 Justification = Suppressions . JsonTrimmingJustification ) ]
7059#pragma warning restore IDE0079 // Remove unnecessary suppression
60+ [ DynamicDependency ( DynamicallyAccessedMemberTypes . All , typeof ( TSMUArgs ) ) ]
61+ [ DynamicDependency ( DynamicallyAccessedMemberTypes . PublicProperties , typeof ( LocalizedString ) ) ]
62+ [ DynamicDependency ( DynamicallyAccessedMemberTypes . PublicProperties , typeof ( LocalizedArgsSentenceBuild ) ) ]
7163 public static void Main ( string [ ] args )
7264 {
7365 Console . OutputEncoding = new UTF8Encoding ( false ) ;
@@ -98,13 +90,7 @@ public static void Main(string[] args)
9890 with . AutoVersion = false ;
9991 with . AllowMultiInstance = true ;
10092 } ) ;
101- var parsed = parser . ParseArguments ( ( ) => new TSMUArgs ( )
102- {
103- AsarPath = string . Empty ,
104- SavPath = string . Empty ,
105- Verbosity = 0 ,
106- DryRun = false
107- } , args ) ;
93+ var parsed = parser . ParseArguments < TSMUArgs > ( args ) ;
10894 parsed . WithParsed ( args =>
10995 {
11096 if ( ! Path . Exists ( args . SavPath = Path . GetFullPath ( args . SavPath ?? string . Empty ) ) )
@@ -149,7 +135,7 @@ public static void Main(string[] args)
149135 opt . IncludeScopes = opt . SingleLine = true ;
150136 opt . TimestampFormat = "[HH:mm:ss.ffffff]" ;
151137 } ) ;
152- cfg . SetMinimumLevel ( ( LogLevel ) Math . Max ( ( int ) ( LogLevel . Information - Args . Verbosity ?? 0 ) , 0 ) ) ;
138+ cfg . SetMinimumLevel ( ( LogLevel ) Math . Max ( ( int ) ( LogLevel . Information - Args . Verbosity ) , 0 ) ) ;
153139 } ) ;
154140 log = logger . CreateLogger ( nameof ( TSMU ) ) ;
155141 var tablelog = LoggerFactory . Create ( cfg =>
@@ -160,13 +146,13 @@ public static void Main(string[] args)
160146 opt . TimestampFormat = "[HH:mm:ss.ffffff]" ;
161147 opt . SingleLine = false ;
162148 } ) ;
163- cfg . SetMinimumLevel ( ( LogLevel ) Math . Max ( ( int ) ( LogLevel . Information - Args . Verbosity ?? 0 ) , 0 ) ) ;
149+ cfg . SetMinimumLevel ( ( LogLevel ) Math . Max ( ( int ) ( LogLevel . Information - Args . Verbosity ) , 0 ) ) ;
164150 } )
165151 . CreateLogger ( nameof ( TSMU ) ) ;
166152
167153 log . LogInformation ( "{title} {build} {copr}. {lic} {dsclmr}" , title , build , copr , lic , dsclmr ) ;
168154
169- if ( Args . DryRun ?? false )
155+ if ( Args . DryRun )
170156 log . LogInformation ( "{Dry}" , LocalizedString . DryModeNotice ) ;
171157
172158 try
@@ -197,7 +183,7 @@ public static void Main(string[] args)
197183 log . LogInformation ( "{count}" , string . Format ( LocalizedString . FoundReplays , replaygallery . Count ) ) ;
198184
199185 FileAccess accs = FileAccess . ReadWrite ;
200- if ( Args . DryRun ?? false )
186+ if ( Args . DryRun )
201187 accs = FileAccess . Read ; // Read-only access for dry run
202188
203189 log . LogInformation ( "{sav}" , string . Format ( LocalizedString . OpenSav , Args . SavPath ) ) ;
@@ -210,7 +196,7 @@ public static void Main(string[] args)
210196 }
211197 while ( File . Exists ( bakfile ) ) ;
212198
213- if ( ! Args . DryRun ?? false )
199+ if ( ! Args . DryRun )
214200 {
215201 log . LogDebug ( "{bak}" , string . Format ( LocalizedString . SavBackup , Args . SavPath , bakfile ) ) ;
216202
@@ -297,7 +283,7 @@ public static void Main(string[] args)
297283 var savjsoned = savjson . ToJsonString ( ) ;
298284 var savjsonen = Uri . EscapeDataString ( savjsoned ) ;
299285
300- if ( Args . DryRun ?? false )
286+ if ( Args . DryRun )
301287 {
302288 log . LogInformation ( "{dry}" , LocalizedString . DryModeNotice ) ;
303289 log . LogDebug ( "{sav}" , string . Format ( LocalizedString . SavingSavDry , Args . SavPath ) ) ;
0 commit comments