-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExportColumnsCommand.cs
38 lines (29 loc) · 1.21 KB
/
ExportColumnsCommand.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using DotMake.CommandLine;
namespace EXDTooler;
[CliCommand(Parent = typeof(MainCommand))]
public sealed class ExportColumnsCommand
{
public required MainCommand Parent { get; set; }
[CliOption(Required = false, Description = "Path to the game directory. Should be the root of the game's repository.", ValidationRules = CliValidationRules.ExistingDirectory)]
public string? GamePath { get; set; }
[CliOption(Required = false, Description = "Path to the columns file generated by export-columns.", ValidationRules = CliValidationRules.ExistingFile)]
public string? ColumnsFile { get; set; }
[CliOption(Required = false, Description = "Path to the output file.")]
public string? OutputPath { get; set; }
public Task RunAsync()
{
var token = Parent.Init();
var sheets = ColDefReader.FromInputs(GamePath, ColumnsFile);
if (OutputPath != null)
{
using var f = File.OpenWrite(OutputPath);
f.SetLength(0);
using var writer = new StreamWriter(f);
sheets.WriteTo(writer);
}
else
sheets.WriteTo(Console.Out);
Log.Info($"Hash: {sheets.HashString}");
return Task.CompletedTask;
}
}