How to catch that there is an error from CommandLineParser so I can return my own error codes? I need to return my own codes when my console application is called from say SSIS.
class Program
{
static void Main(string[] args)
{
try
{
var myParserResult = Parser.Default.ParseArguments<UploadFileCommand, DownloadFileCommand, CompressFileCommand>(args)
.WithParsed<ICommand>(t => t.Execute());
var parsed = myParserResult as NotParsed<object>;
if (parsed != null && parsed.Errors.Any())
{
Console.WriteLine("Has Errors");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}