Skip to content
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

parsing fails when value matches name of list parameter #396

Closed
vemoo opened this issue Jan 22, 2019 · 5 comments
Closed

parsing fails when value matches name of list parameter #396

vemoo opened this issue Jan 22, 2019 · 5 comments

Comments

@vemoo
Copy link

vemoo commented Jan 22, 2019

class Options
{
    [Option("deploy", Separator = ',', = "Projects to deploy")]
    public IList<string> Deploys { get; set; }

    [Option("profile", Required = true, HelpText = "Profile to use when restoring and publishing")]
    public string Profile { get; set; }

    [Option("configure-profile", Required = true, HelpText = "Profile to use for Configure")]
    public string ConfigureProfile { get; set; }
}

Parsing fails if passed --configure-profile deploy --profile local with Required option 'profile' is missing.
I think it's intepreting the deploy value as an option.

@moh-hassan
Copy link
Collaborator

moh-hassan commented Aug 19, 2020

@rmunn
This is a known issue in the library, see this test case.
Please, can you help in fixing this issue?

@rmunn
Copy link
Contributor

rmunn commented Aug 20, 2020

@moh-hassan Interesting. I'll take a look.

@rmunn
Copy link
Contributor

rmunn commented Aug 20, 2020

Initial findings: the tokenizer returned a Name token for --configure-profile, followed by three Value tokens for deploy, --profile (which is wrong, should have been a Name token) and local.

But I just stepped through the tokenizer and watched it happen, and the tokenizer initially returned a Name token for --profile. But then inside the Tokenizer.ExplodeOptionList method, that Name token was turned into a Value token. So the ExplodeOptionList method is the culprit. I'll continue tracking it down and report more.

BTW, my GetoptTokenizer implementation from PR #684 also contains this bug, because I re-used that ExplodeOptionList method without any changes. So when I find and fix this bug, I'll also submit an update to PR #684. Please don't merge #684 until then, or you'll be merging known-buggy code that I'm working on a fix for.

@rmunn
Copy link
Contributor

rmunn commented Aug 20, 2020

Related, though not the same bug: #687 (which I'll also submit a fix for).

@rmunn
Copy link
Contributor

rmunn commented Aug 20, 2020

PR #684 now has a fix for this bug (in commit 47618e0).

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

No branches or pull requests

3 participants