Replace System.CommandLine with CliFx
This commit is contained in:
parent
350a891118
commit
f5fa373519
|
@ -8,7 +8,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
|
<PackageReference Include="clifx" Version="2.3.5" />
|
||||||
<PackageReference Include="TinyEmbree" Version="1.0.3" />
|
<PackageReference Include="TinyEmbree" Version="1.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -1,46 +1,38 @@
|
||||||
using System.CommandLine;
|
using CliFx;
|
||||||
|
using CliFx.Attributes;
|
||||||
|
using IConsole = CliFx.Infrastructure.IConsole;
|
||||||
|
|
||||||
namespace KeepersCompound.Lightmapper;
|
namespace KeepersCompound.Lightmapper;
|
||||||
|
|
||||||
class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
private static void Main(string[] args)
|
public static async Task<int> Main() =>
|
||||||
{
|
await new CliApplicationBuilder().AddCommandsFromThisAssembly().Build().RunAsync();
|
||||||
var installPathArg = new Argument<string>(
|
}
|
||||||
"installPath",
|
|
||||||
"The path to the root Thief installation.");
|
|
||||||
var campaignNameArg = new Argument<string>(
|
|
||||||
"campaignName",
|
|
||||||
"The folder name of the fan mission. For OMs this is blank.");
|
|
||||||
var missionNameArg = new Argument<string>(
|
|
||||||
"missionName",
|
|
||||||
"The name of the mission file including extension.");
|
|
||||||
var outputFileOption = new Option<string>(
|
|
||||||
["-o", "--output"],
|
|
||||||
() => "kc_lit",
|
|
||||||
"Name of output file excluding extension.");
|
|
||||||
var multiSamplingOption = new Option<bool>(
|
|
||||||
"--multiSampling",
|
|
||||||
() => false,
|
|
||||||
"Enables multi-sampled shadows. Higher quality but slower.");
|
|
||||||
|
|
||||||
var rootCommand = new RootCommand("Compute lightmaps for a NewDark .MIS/.COW");
|
[Command(Description = "Compute lightmaps for a NewDark .MIS/.COW")]
|
||||||
rootCommand.AddArgument(installPathArg);
|
public class LightCommand : ICommand
|
||||||
rootCommand.AddArgument(campaignNameArg);
|
{
|
||||||
rootCommand.AddArgument(missionNameArg);
|
[CommandParameter(0, Description = "The path to the root Thief installation.")]
|
||||||
rootCommand.AddOption(outputFileOption);
|
public required string InstallPath { get; init; }
|
||||||
rootCommand.AddOption(multiSamplingOption);
|
[CommandParameter(1, Description = "The folder name of the fan mission. For OMs this is blank.")]
|
||||||
rootCommand.SetHandler((installPath, campaignName, missionName, outputFile, multiSampling) =>
|
public required string CampaignName { get; init; }
|
||||||
|
[CommandParameter(2, Description = "The name of the mission file including extension.")]
|
||||||
|
public required string MissionName { get; init; }
|
||||||
|
[CommandOption("output", 'o', Description = "Name of output file excluding extension.")]
|
||||||
|
public string OutputName { get; init; } = "kc_lit";
|
||||||
|
[CommandOption("multiSampling", 'm', Description = "Enables multi-sampled shadows. Higher quality but slower.")]
|
||||||
|
public bool MultiSampling { get; init; } = false;
|
||||||
|
|
||||||
|
public ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
Timing.Reset();
|
Timing.Reset();
|
||||||
|
|
||||||
var lightMapper = new LightMapper(installPath, campaignName, missionName);
|
var lightMapper = new LightMapper(InstallPath, CampaignName, MissionName);
|
||||||
lightMapper.Light(multiSampling);
|
lightMapper.Light(MultiSampling);
|
||||||
lightMapper.Save(outputFile);
|
lightMapper.Save(OutputName);
|
||||||
|
|
||||||
Timing.LogAll();
|
Timing.LogAll();
|
||||||
}, installPathArg, campaignNameArg, missionNameArg, outputFileOption, multiSamplingOption);
|
return default;
|
||||||
|
|
||||||
rootCommand.Invoke(args);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue