jtr/DevDisciples.Json.Tools.CLI/JsonUglifyCommand.cs
2024-09-15 17:23:27 +02:00

23 lines
729 B
C#

using System.CommandLine;
using DevDisciples.Json.Tools.CLI.Extensions;
namespace DevDisciples.Json.Tools.CLI;
public class JsonUglifyCommand : Command
{
public JsonUglifyCommand() : base("uglify", "Uglify JSON")
{
AddAlias("u");
this.AddIOCommandOptions();
this.SetHandler(ExecuteAsync, new CommandOptionsBinder());
}
private static async Task ExecuteAsync(CommandOptions options)
{
var json = await IOHandler.HandleInput(options.Input, options.InputArgument, options.InputFile);
var output = JsonFormatter.Format(json, new() { Beautify = false });
await IOHandler.HandleOutput(options.Output, options.OutputFile, output);
}
}