1

I am using commandLineParser version 2.5.0 https://github.com/commandlineparser/commandline/wiki. If there is an error, I am unable to parse which command line options are invalid. I can only find out the type of error from Current.Tag. How do I know which command line option had error?

 public static void Main(string[] args)
    {
        Parser.Default.ParseArguments<CommandLineOptions>(args)
        .WithParsed(opts => ParseCommandLineArguments(opts))
        .WithNotParsed((errs) => HandleParseError(errs));
    }

    private static void HandleParseError(IEnumerable<Error> errs)
    {

        IEnumerator<Error> enumerator = errs.GetEnumerator();
        while (enumerator.MoveNext())
        {
            Console.WriteLine(enumerator.Current.Tag.ToString());
        }

    }
4

0 回答 0