Skip to content

Commit 2f3d123

Browse files
committed
Hook up verification mode to tool
1 parent 12ae3a0 commit 2f3d123

File tree

1 file changed

+41
-14
lines changed

1 file changed

+41
-14
lines changed

TACTTool/Program.cs

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ private enum InputMode
1616
FileName
1717
};
1818

19+
private enum RunMode
20+
{
21+
Extract,
22+
Verify
23+
};
24+
25+
private static RunMode RunModeSetting = RunMode.Extract;
1926
private static InputMode? Mode;
2027
private static string? Input;
2128
private static string? Output;
@@ -48,7 +55,7 @@ static async Task Main(string[] args)
4855
localeOption.Aliases.Add("-l");
4956
rootCommand.Options.Add(localeOption);
5057

51-
var inputModeOption = new Option<string>("--mode") { Description = "Input mode: list, ekey (or ehash), ckey (or chash), id (or fdid), name (or filename)" };
58+
var inputModeOption = new Option<string>("--mode") { Description = "Input mode: list, ekey (or ehash), ckey (or chash), id (or fdid), name (or filename), verify (non-extraction, verify CDN dir contents)" };
5259
inputModeOption.Aliases.Add("-m");
5360
rootCommand.Options.Add(inputModeOption);
5461

@@ -77,6 +84,12 @@ static async Task Main(string[] args)
7784

7885
await rootCommand.Parse(args).InvokeAsync();
7986

87+
if(RunModeSetting == RunMode.Verify)
88+
{
89+
RunModes.Verify.Run(build);
90+
return;
91+
}
92+
8093
if (build.Settings.BuildConfig == null || build.Settings.CDNConfig == null)
8194
{
8295
Console.WriteLine("Missing build or CDN config, exiting..");
@@ -225,20 +238,26 @@ private static async Task CommandLineArgHandler(ParseResult result)
225238
Output = optionValue;
226239
break;
227240
case "--mode":
228-
Mode = (optionValue).ToLower() switch
241+
RunModeSetting = optionValue.Equals("verify", StringComparison.CurrentCultureIgnoreCase) ? RunMode.Verify : RunMode.Extract;
242+
243+
if(RunModeSetting == RunMode.Extract)
229244
{
230-
"list" => InputMode.List,
231-
"ehash" => InputMode.EKey,
232-
"ekey" => InputMode.EKey,
233-
"chash" => InputMode.CKey,
234-
"ckey" => InputMode.CKey,
235-
"id" => InputMode.FDID,
236-
"fdid" => InputMode.FDID,
237-
"install" => InputMode.FileName,
238-
"filename" => InputMode.FileName,
239-
"name" => InputMode.FileName,
240-
_ => throw new Exception("Invalid input mode. Available modes: list, ekey/ehash, ckey/chash, fdid/id, filename/name"),
241-
};
245+
Mode = (optionValue).ToLower() switch
246+
{
247+
"list" => InputMode.List,
248+
"ehash" => InputMode.EKey,
249+
"ekey" => InputMode.EKey,
250+
"chash" => InputMode.CKey,
251+
"ckey" => InputMode.CKey,
252+
"id" => InputMode.FDID,
253+
"fdid" => InputMode.FDID,
254+
"install" => InputMode.FileName,
255+
"filename" => InputMode.FileName,
256+
"name" => InputMode.FileName,
257+
_ => throw new Exception("Invalid input mode. Available modes: list, ekey/ehash, ckey/chash, fdid/id, filename/name"),
258+
};
259+
}
260+
242261
break;
243262
case "--cdndir":
244263
build!.Settings.CDNDir = optionValue;
@@ -255,6 +274,14 @@ private static async Task CommandLineArgHandler(ParseResult result)
255274
}
256275
}
257276

277+
if(RunModeSetting == RunMode.Verify)
278+
{
279+
if(string.IsNullOrEmpty(build!.Settings.CDNDir))
280+
throw new Exception("CDN directory must be specified for verify mode.");
281+
282+
return;
283+
}
284+
258285
if (Mode == null)
259286
{
260287
Console.WriteLine("No input mode specified. Available modes: list, ekey, ckey, fdid, filename. Run with -h or --help for more information.");

0 commit comments

Comments
 (0)