Add CLI verbs

This commit is contained in:
Tim Van Baak 2024-08-16 13:33:13 -07:00
parent eaafdeb5a9
commit 6bb6c0695f
5 changed files with 74 additions and 8 deletions

View File

@ -0,0 +1,15 @@
using CommandLine;
namespace MultiversalDiplomacy.CommandLine;
[Verb("adjudicate", HelpText = "Adjudicate a Multiversal Diplomacy game state.")]
public class AdjudicateOptions
{
[Value(0, HelpText = "Input file describing the game state to adjudicate, or - to read from stdin.")]
public string? InputFile { get; set; }
public static void Execute(AdjudicateOptions args)
{
throw new NotImplementedException();
}
}

View File

@ -0,0 +1,15 @@
using CommandLine;
namespace MultiversalDiplomacy.CommandLine;
[Verb("image", HelpText = "Generate an image of a game state.")]
public class ImageOptions
{
[Value(0, HelpText = "Input file describing the game state to visualize, or - to read from stdin.")]
public string? InputFile { get; set; }
public static void Execute(ImageOptions args)
{
throw new NotImplementedException();
}
}

View File

@ -0,0 +1,12 @@
using CommandLine;
namespace MultiversalDiplomacy.CommandLine;
[Verb("repl", HelpText = "Begin an interactive 5dplomacy session.")]
public class ReplOptions
{
public static void Execute(ReplOptions args)
{
throw new NotImplementedException();
}
}

View File

@ -13,4 +13,8 @@
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
</ItemGroup>
</Project>

View File

@ -1,12 +1,32 @@
using System;
using CommandLine;
namespace MultiversalDiplomacy
using MultiversalDiplomacy.CommandLine;
namespace MultiversalDiplomacy;
internal class Program
{
internal class Program
[Verb("stab", HelpText = "stab")]
private class StabOptions
{
static void Main(string[] args)
{
Console.WriteLine("stab");
}
public static void Execute(StabOptions _)
=> Console.WriteLine("stab");
}
static void Main(string[] args)
{
var parser = Parser.Default;
var parseResult = parser.ParseArguments(
args,
typeof(AdjudicateOptions),
typeof(ImageOptions),
typeof(ReplOptions),
typeof(StabOptions));
parseResult
.WithParsed<AdjudicateOptions>(AdjudicateOptions.Execute)
.WithParsed<ImageOptions>(ImageOptions.Execute)
.WithParsed<ReplOptions>(ReplOptions.Execute)
.WithParsed<StabOptions>(StabOptions.Execute);
}
}