0

I am currently working on a console app which uses this command line parser library. Some of my option values should be Integers. So I was wondering if there is a way to specify these options in such a way that they only accept values of type int.

I already read through the documentary of the library but didn't find such functionality. But maybe I missed something.

Thank you for your help!

arne.z
  • 3,242
  • 3
  • 24
  • 46

1 Answers1

2

Apparently all you have to do is declare the return type as an int. This example is in the documentation:

[Option("l", "length", HelpText = "The maximum number of bytes to process.")]
  public int MaximumLength { get; set; };
// ...
}

The following will be accepted.
  GuideApp --length=99
  GuideApp -l12345
  GuideApp -l 555
The following will be rejected.
  GuideApp --length=a-string
  GuideApp -lsome_text
  GuideApp -l text.again
codingatty
  • 2,026
  • 1
  • 23
  • 32
pCarsten
  • 68
  • 5