Skip to content

StartOption

Lunar Doggo edited this page Jul 24, 2021 · 7 revisions

What is it?

A StartOption represents a command line parameter the StartOptionParser should be able to parse, they can either be groupless or included in a StartOptionGroup. Instances of this class can only built by using a StartOptionBuilder.

StartOptions have a short and long name, with default StartOptionParserSettings they are used like this:

long name "optionname":

root@example-pc ~# ./demoapp --optionname

short name "o":

root@example-pc ~# ./demoapp -o

Implementation

public class StartOption : IClonable<StartOption>

Constructor

internal StartOption(string, string, string, IStartOptionValueParser, StartOptionValueType, bool)

This constructor is only used internally by StartOptionBuilder

Properties

Signature Description
public StartOptionValueType ValueType { get; } Possible values: Switch, Single, Multiple. Indicates, whether the StartOption can have no, one or multiple values
public string Description { get; } Description of the StartOption shown on the help page
public string ShortName { get; } Short name of the StartOption
public string LongName { get; } Long name of the StartOption
public bool IsRequired { get; } Flag, whether the StartOption must be set or it can be left unused
public bool HasValue { get; } Flag, whether the StartOption contains a value or not

Methods

Signature Description
public T GetValue<T>() Returns the value of the StartOption if the parser assigned one to it, otherwise, the default value of Type T will be returned
internal void ParseSingleValue(string) Parses the value string the parser assigned to the StartOption into a single value
internal void ParseMultipleValues(string[]) Parses the value string the parser assigned to the StartOption into multiple values
public StartOption Clone() Creates a new instance of StartOption with the same values

Note: A StartOption can use custom IStartOptionValueParsers to parse its values. Further info: StartOptionValueParsers