Skip to content

Commit 50647a1

Browse files
committed
typo 3
revert args nullables preserve dynamics
1 parent 6338f85 commit 50647a1

3 files changed

Lines changed: 17 additions & 30 deletions

File tree

Program.cs

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -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));

Res/LocalizedString.ja.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
<value>シナリオ ファイル:</value>
185185
</data>
186186
<data name="HelpTextAsar" xml:space="preserve">
187-
<value>ゲームのシナリオ ファイルを含む「.asar」ファイルのパス(通常は [resources/] フォルダ内)</value>
187+
<value>ゲームのシナリオ ファイルを含む「.asar」ファイルのパス(通常は'resources/'フォルダ内)</value>
188188
</data>
189189
<data name="HelpTextDesc" xml:space="preserve">
190190
<value>{1}説明:{1} {0}{1}{1}使い方:{1} tsmu [options] -a &lt;path&gt; -s &lt;path&gt;{1}{1} &lt;path&gt; {2}{1}{1}オプション・Options:</value>

TyranoScriptMemoryUnlocker.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ See <https://www.gnu.org/licenses/>.
2222

2323
<Copyright>(C) 2025 $(Company), $(Authors)</Copyright>
2424

25-
<Version>0.3.2</Version>
25+
<Version>0.3.4</Version>
2626
<InformationalVersion>v$(Version)</InformationalVersion>
2727
<Changelog>
2828
- v0.1.0: Initial release, basic functionality implemented.
@@ -36,6 +36,7 @@ See <https://www.gnu.org/licenses/>.
3636
- v0.3.3: Revert help option addition.
3737
Added license and readme to release files.
3838
Miniscule typos fixed.
39+
- v0.3.4: Fix command line argument parsing issues. (revert nullables)
3940
</Changelog>
4041
</PropertyGroup>
4142

0 commit comments

Comments
 (0)