Skip to content

Feature request: .NotNull() check for command options #97

Open
@agracio

Description

@agracio

It would be great if both required and optional options could be marked as NotNull with parser throwing exception if empty value is passed. The check should work for any object type, not only strings.
Example

var p = new FluentCommandLineParser<ApplicationArguments>();

   p.Setup(arg => arg.RecordId)
    .As('r', "record") 
    .Required(); 

   p.Setup(arg => arg.NewValue)
    .As('v', "value")
    .Required().NotNull(); // <- ensures that -v|--value is not empty

   p.Setup(arg => arg.Silent)
    .As('s', "silent")
    .SetDefault(false);

Current implementation allows command line to have ---value without any actual value so 'not null or empty' checks need be done separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions