Skip to content

StartOptionBuilder

Lunar Doggo edited this page Jul 24, 2021 · 1 revision

What is it?

A StartOptionBuilder is used to create instances of the StartOption class.

Implementation

public class StartOptionBuilder : AbstractOptionBuilder<StartOption>

Constructor

public StartOptionBuilder(string longName, string shortName)

Initializes the builder with the most basic properties of a StartOption: its long and short name

Methods

Signature Description
public StartOptionBuilder SetValueParser(IStartOptionValueParser) Sets the type of value parser to be used for values assigned to the StartOption (List of predefined value parsers)
public StartOptionBuilder SetValueType(StartOptionValueType) Sets, whether the StartOption can have values or not. Possible values: Switch, Single, Multiple; if not set otherwise, it will automatically default to Switch
public StartOptionBuilder SetDescription(string) Sets the description of the StartOption to be displayed on the help page
public StartOptionBuilder SetRequired(bool) Sets whether the StartOption is required to be set. If the option is inside a StartOptionGroup, the required flag will only come into effect, if the StartOptionGroup is selected by the user
public override StartOption Build() Creates a new instance of StartOption with the previously set parameters

Examples

Most basic:

StartOption option = new StartOptionBuilder("option", "o").Build();

Single int value:

StartOption option = new StartOptionBuilder("option", "o").SetValueType(StartOptionValueType.Single)
                             .SetValueParser(new Int32OptionValueParser()).Build();

Custom description and required:

StartOption option = new StartOptionBuilder("option", "o").SetDescription("Custom description for required option")
                             .SetRequired().Build();

All set:

StartOption option = new StartOptionBuilder("option", "o").SetValueType(StartOptionValueType.Single)
                             .SetValueParser(new Int32OptionValueParser()).SetDescription("This option uses all builder methods!")
                             .SetRequired().Build();