mayuki / Cocona

Micro-framework for .NET console application. Cocona makes it easy and fast to build console applications on .NET.
MIT License
3.26k stars 85 forks source link

3-state support - Option with [HasDefaultValue] that has a default value defined still requires the value #149

Open Simonl9l opened 4 months ago

Simonl9l commented 4 months ago

per https://github.com/mayuki/Cocona/pull/31#issue-960283993 - I seem be missing something but the note says

NOTE: Option defined as a property is treated as required by default. If you want a non-required Option to have a default value, mark it with HasDefaultValue attribute.

if would be great to have:

 public record MyCommandOptions : ICommandParameterSet
  {

      [Option('T', Description = "a default 3 state option")]
      [HasDefaultValue]
      public string ThreeStateWithDefault { get; set; } = "";

...
}

such that once can just specify -T or --three-state-with-default with out a following value, and the default value would be used. The option then acts as a switch (like a bool) and can have a user value supplied is needed that overrides the default.

Currently we need to also supply a value.