Cocona icon indicating copy to clipboard operation
Cocona copied to clipboard

ICommandParameterSet does not abide by nullability rules

Open Allann opened this issue 1 year ago • 1 comments

I have the following record defined and use this in a few commands, however each of the properties are mandatory according to the usage and help information even though I marked them as nullable.

public record ConfigurationParameters:ICommandParameterSet
{
    [Option('t', Description = "Folder where Templates are located.")]
    public string? TemplateFolder { get; init; }

    [Option('d', Description = "Folder where Definitions are located.")]
    public string? DefinitionFolder{ get; init; }

    [Option(Description = "The target framework to use (default: net8.0).")]
    public string? Target { get; init; }    
}
Usage: Modeller.Tool list [--template-folder <String>] [--definition-folder <String>] [--target <String>] [--help]

List the definition and generator folders

Options:
  -t, --template-folder <String>      Folder where Templates are located. (Required)
  -d, --definition-folder <String>    Folder where Definitions are located. (Required)
  --target <String>                   The target framework to use (default: net8.0). (Required)
  -h, --help                          Show help message

Is there something I missed that I should have done to correctly implement ICommandParameterSet?

Allann avatar Jan 02 '24 01:01 Allann

You need to add [HasDefaultValue] to the options you want to make optionnal.

Tagachi avatar Mar 01 '24 11:03 Tagachi