Skip to content

Usage is printed when all options have default values #60

@Matthiee

Description

@Matthiee

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions