Skip to content

StartOptionGroupBuilder

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

What is it?

A StartOptionGroupBuilder is used to create instances of StartOptionGroups.

Implementation

public class StartOptionGroupBuilder : AbstractOptionBuilder<StartOptionGroup>

Constructor

public StartOptionGroupBuilder(string longName, string shortName)

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

Methods

Signature Description
public StartOptionGroupBuilder SetDescription(string description) Sets the description displayed on the help page for the StartOptionGroup
public StartOptionGroupBuilder AddOption(string, string, Action<StartOptionBuilder>) Adds a new StartOption to the group, the long/short name and build action have to be supplied in order to build the option to be added
public StartOptionGroupBuilder AddOption(StartOption option) Adds a new, already built StartOption to the group
public override StartOptionGroup Build() Creates a new instance of StartOptionGroup with the previously set parameters
private void CheckForNameDuplications(StartOption newOption) Checks whether the long or short name of a StartOption conflicts with the name of a already added StartOption or the name of the StartOptionGroup. If a duplication is detected, a NameConflictException will be raised. Called by AddOption()
private void CheckOptionsNameConflicts(StartOption newOption) Checks whether the long or short name of a StartOption conflicts with the name of the StartOptionGroup. If a duplication is detected, a NameConflictException will be raised. Called by CheckForNameDuplications()

Examples

AddOption with StartOption builder:

StartOptionGroup group = new StartOptionGroupBuilder("group", "g")
                             .AddOption("option", "o", (_builder) => { _builder.SetDescription("additional option").SetRequired(); })
                             .SetDescription("Group with additional option").Build()

AddOption with previously created StartOption:

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

StartOptionGroup group = new StartOptionGroupBuilder("group", "g")
                             .AddOption(option).SetDescription("Group with additional option").Build()