Skip to content

Could two or more options be marked as 'at least one is required'? #546

@hadzhiyski

Description

@hadzhiyski

Hello,

This is not particularly an issue. I was wondering could I make two or more options to act like at least one of them is required, but if none is provided I will get a required error?

[Verb("rename")]
public sealed class RenameOptions
{
    [Option("prefix", HelpText = "Prefix to append to file name", SetName = "rename", Required = true)]
    public string Prefix { get; set; }

    [Option("suffix", HelpText = "Suffix to append to file name", SetName = "rename", Required = true)]
    public string Suffix { get; set; }
}

This works if both options are included. Could I make them to work separately or together, but always one should be provided?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions