question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IgnoreUnknownArguments does not work for values

See original GitHub issue

Issue by cdmihai Wednesday Aug 09, 2017 at 20:14 GMT _Originally opened as https://github.com/gsscoder/commandline/issues/467_


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 😃

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:8

github_iconTop GitHub Comments

2reactions
sybariscommented, Jan 10, 2018

Hi,

I have the same issue… It is planned to be fixed ?

Thanks for advance Sybaris

1reaction
moh-hassancommented, May 20, 2020

This is needed when you need to pass through args to third party tool like Unity Engine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apache Commons CLI 1.3.1: How to ignore unknown ...
I used to work with Apache Commons Cli 1.2. I wanted the parser to ignore arguments if they are unknown (not added to...
Read more >
How to handle invalid arguments with argparse in Python?
To use this a variable that refers to the argument should be set up. Look at the example below. The program takes two...
Read more >
Parsing arguments and building values
The variables which correspond to optional parameters not given by args will not be filled in; these should be initialized by the caller....
Read more >
Function arguments - Manual
A function may define default values for arguments using syntax similar to assigning a variable. The default is used only when the parameter...
Read more >
jsonargparse — jsonargparse documentation
First, the purpose is not allowing to call any python object from the command line. It is only intended for running functions and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found