From bd51a23da369b509b8198013ae330a729b3f6760 Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Mon, 16 May 2022 02:25:54 -0500 Subject: [PATCH] Program now compiles. Still untested. --- DotNetResxUtils/Commands/GenerationCommand.cs | 12 +++++------- DotNetResxUtils/Program.cs | 13 ++----------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/DotNetResxUtils/Commands/GenerationCommand.cs b/DotNetResxUtils/Commands/GenerationCommand.cs index e6f6f23..0ddec8f 100644 --- a/DotNetResxUtils/Commands/GenerationCommand.cs +++ b/DotNetResxUtils/Commands/GenerationCommand.cs @@ -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 fromOpt = new Option("--from", "Generates a .resx file from the given file."); Argument destArg = new Argument("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(CommandHandler, destArg, fromOpt); + this.SetHandler(CommandHandler, destArg, fromOpt); } private async void CommandHandler(FileInfo to, FileInfo? from) { diff --git a/DotNetResxUtils/Program.cs b/DotNetResxUtils/Program.cs index d217a3f..7dbe381 100644 --- a/DotNetResxUtils/Program.cs +++ b/DotNetResxUtils/Program.cs @@ -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 convertOpt = new Option("--convert", "Generates a .resx file from the given file. Currently only supports .json files."); - genCmd.AddOption(convertOpt); - - Argument destArg = new Argument("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)) } } } \ No newline at end of file