Program now compiles. Still untested.

This commit is contained in:
Harrison Deng 2022-05-16 02:25:54 -05:00
parent 68cd4fdcf2
commit bd51a23da3
2 changed files with 7 additions and 18 deletions

View File

@ -7,24 +7,22 @@ using System.Resources.NetStandard;
namespace DotNetResxUtils.Commands
{
internal class GenerationCommand
internal class GenerationCommand : Command
{
const string NAME = "generate";
const string DESC = "Generate a .resx file.";
public GenerationCommand(RootCommand rootCmd)
public GenerationCommand() : base(NAME, DESC)
{
Command cmd = new Command(NAME, DESC);
rootCmd.AddCommand(cmd);
Option<FileInfo?> fromOpt = new Option<FileInfo?>("--from", "Generates a .resx file from the given file.");
Argument<FileInfo> destArg = new Argument<FileInfo>("destination", "The destination path to store this file. If no extension is given, .resx will automatically be concatenated.");
cmd.AddOption(fromOpt);
cmd.AddArgument(destArg);
this.AddOption(fromOpt);
this.AddArgument(destArg);
cmd.SetHandler<FileInfo, FileInfo?>(CommandHandler, destArg, fromOpt);
this.SetHandler<FileInfo, FileInfo?>(CommandHandler, destArg, fromOpt);
}
private async void CommandHandler(FileInfo to, FileInfo? from)
{

View File

@ -1,6 +1,7 @@
using System.IO;
using System;
using System.CommandLine;
using DotNetResxUtils.Commands;
namespace DotNetResxUtils
{
@ -9,19 +10,9 @@ namespace DotNetResxUtils
static void Main(string[] args)
{
RootCommand rootCmd = new RootCommand(".Net Resx Utils provides tools for generating, and editing .resx files.");
Command genCmd = new Command("gen", "Generate a .resx file.");
rootCmd.AddCommand(genCmd);
rootCmd.AddCommand(new GenerationCommand());
// See: Collection organizers - https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/object-and-collection-initializers
Option<FileInfo?> convertOpt = new Option<FileInfo?>("--convert", "Generates a .resx file from the given file. Currently only supports .json files.");
genCmd.AddOption(convertOpt);
Argument<string> destArg = new Argument<string>("destination", "The destination path to store this file. If no extension is given, .resx will automatically be concatenated.");
genCmd.AddArgument(destArg);
genCmd.SetHandler(async (string dst, FileInfo? from))
}
}
}