Skip to content

IgnoreUnknownArguments does not work for values #467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cdmihai opened this issue Aug 9, 2017 · 0 comments
Open

IgnoreUnknownArguments does not work for values #467

cdmihai opened this issue Aug 9, 2017 · 0 comments
Labels

Comments

@cdmihai
Copy link

cdmihai commented Aug 9, 2017

Given the following snippet where ParserSettings.IgnoreUnknownArguments = false:

using System;
using CommandLine;

namespace Cmd
{
    class Program
    {
        static void Main(string[] args)
        {
            var parser = new Parser(with => 
                {
                    with.IgnoreUnknownArguments = false;
                    with.HelpWriter = Console.Out;
                });

            var result = parser.ParseArguments<Options>(args);
            result.WithParsed(options => Console.WriteLine(options.anInt));
        }
    }

    class Options {
        [Option('i', HelpText = "an int")]
        public int anInt { get; set; }
    }
}

And given the invocation:
app.exe bogus args

I would expect the parser to error out saying it does not understand the unknown arguments bogus args.
Instead, it does not error out.

Context: I have an optional argument (e.g. -a value) and I had forgotten to type in the argument name (-a), I typed in just the value. Instead of having the command line parser fail on encountering value, it continued working, causing quite a bit of debugging time :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants