ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,404 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I am using CommandLineParser C# library to parse in new commands to my application, I wonder if there is a way to show or print out the errors from not passing one command not as a general error. I mean in case if one command is missing how to show exactly the missing command error.
Thanks in advance.
Here is my code snippet
var result = Parser.Default.ParseArguments<CommandLineOptions>(args)
.MapResult(async (CommandLineOptions opts) =>
{
cmd = opts;
return 0;
},
errs => Task.FromResult(-1)
);
if (result.Result == -1)
{
Console.WriteLine("Error in parsing line commands"); // is there a way to tell them what was wrong i.e. which particular
// /argument was bad
}
else
{
if (cmd.Validate())
{
RunAsync().GetAwaiter().GetResult();
}
}
}