Skip to content

Usage is printed when all options have default values #60

New issue

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

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

Already on GitHub? # to your account

Closed
Matthiee opened this issue Nov 22, 2019 · 0 comments · Fixed by #63
Closed

Usage is printed when all options have default values #60

Matthiee opened this issue Nov 22, 2019 · 0 comments · Fixed by #63
Assignees
Labels
bug Something isn't working Customer Reported Bugs reported by customers good first issue Good for newcomers help wanted Extra attention is needed
Milestone

Comments

@Matthiee
Copy link
Member

Matthiee commented Nov 22, 2019

Description

I have an option specified as

[Name("c", "check")]
[Description("Reports the amount of duplicates without changing anything")]
[DefaultValue(true)] // Note defaults to true and not required
public bool OnlyCheck { get; set; }

But still it prints the usages when it should not print them in this case.

Run without specifying the "check" option as CLI argument.

Workaround

Current workaround: setting AutoPrintUsageAndErrors = false.

Todo

Problem is caused by CommandLineParser`TOption.cs#L255-L265.

We wrongly assume noArgsSupplied means we should print the usage.
This is mostly correct but there is a scenario where this shouldn't.

A scenario where we only have optional options that have at least one with DefaultValue specified.

@Matthiee Matthiee added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers Customer Reported Bugs reported by customers labels Nov 22, 2019
@Matthiee Matthiee added this to the 0.3.vNext milestone Nov 22, 2019
@Matthiee Matthiee self-assigned this Feb 23, 2020
@Matthiee Matthiee linked a pull request Feb 23, 2020 that will close this issue
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working Customer Reported Bugs reported by customers good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant