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

21 lines
654 B
C#

using System.CommandLine.Builder;
using System.CommandLine.Parsing;
using DevDisciples.Json.Tools.CLI;
var parser = new CommandLineBuilder(new RootCommand())
.UseDefaults()
.UseExceptionHandler((ex, ctx) =>
{
/*
* Use a custom ExceptionHandler to prevent the System.CommandLine library from printing the StackTrace by default.
*/
Console.WriteLine(ex.Message);
/*
* Set the exit code to a non-zero value to indicate to the shell that the process has failed.
*/
Environment.ExitCode = -1;
})
.Build();
await parser.InvokeAsync(args);