Skip to content

Can I add validate feature in Set parameter, and throw exception, and show usage? #283

@Wenduan-Mou

Description

@Wenduan-Mou

Can I add validate feature in Set parameter, and throw exception, and show usage?
is there exception handling in command line parameter parsing?

[Option(
'f', "filename",
HelpDesk = "Specifies the input file")]
public string Name
{
get { return mName; }
set
{
Regex regex = new Regex("^[0-9a-z]+.txt$");

     if (regex.Match(value).Success )
        throw new InvalidOptionValueException(
            "The name must be txt file", false);
     mName = value;
  }

}
Private string mName;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No 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