Program now compiles. Still untested.
This commit is contained in:
parent
68cd4fdcf2
commit
bd51a23da3
@ -7,24 +7,22 @@ using System.Resources.NetStandard;
|
|||||||
|
|
||||||
namespace DotNetResxUtils.Commands
|
namespace DotNetResxUtils.Commands
|
||||||
{
|
{
|
||||||
internal class GenerationCommand
|
internal class GenerationCommand : Command
|
||||||
{
|
{
|
||||||
const string NAME = "generate";
|
const string NAME = "generate";
|
||||||
const string DESC = "Generate a .resx file.";
|
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.");
|
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.");
|
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);
|
this.AddOption(fromOpt);
|
||||||
cmd.AddArgument(destArg);
|
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)
|
private async void CommandHandler(FileInfo to, FileInfo? from)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System;
|
using System;
|
||||||
using System.CommandLine;
|
using System.CommandLine;
|
||||||
|
using DotNetResxUtils.Commands;
|
||||||
|
|
||||||
namespace DotNetResxUtils
|
namespace DotNetResxUtils
|
||||||
{
|
{
|
||||||
@ -9,19 +10,9 @@ namespace DotNetResxUtils
|
|||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
RootCommand rootCmd = new RootCommand(".Net Resx Utils provides tools for generating, and editing .resx files.");
|
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(new GenerationCommand());
|
||||||
rootCmd.AddCommand(genCmd);
|
|
||||||
|
|
||||||
// See: Collection organizers - https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/object-and-collection-initializers
|
// 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))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user