DotNet-Arguments 2.0.0
A simple and 'to-the-point' library to parse launch arguments in .NET and .NET Core applications.
Loading...
Searching...
No Matches
NibblePoker.Library.Arguments.Verb Class Reference

Class Verb models a verb that can be given in launch arguments to select a specific action or subset of usable launch parameters. More...

Public Member Functions

 Verb (string name, string description="")
 Constructs an independant Verb with the given parameters. More...
 
Verb RegisterVerb (Verb verb)
 Attempts to register a sub-Verb in the current Verb. More...
 
Verb RegisterOption (Option option)
 Attempts to register an Option in the current Verb. More...
 
Verb RegisterOptionRecursively (Option option, bool ignoreDuplicates=false)
 Attempts to register an Option in the current Verb and all its sub-Verb in a recursive manner. More...
 
Verb GetSubVerbByName (string name)
 Attempts to retrieve a registered sub-Verb using its name. More...
 
Option GetRelevantDefaultOption ()
 Attempts to retrieve the default Option that should be used during the parsing process based on whether it has been used before. More...
 
Option GetOptionByToken (char token)
 Attempts to retrieve a registered Option using its token. More...
 
Option GetOptionByName (string name)
 Attempts to retrieve a registered Option using its name. More...
 
bool HasOptionByToken (char token)
 Checks if a given token is used by a registered Option. More...
 
bool HasOptionByName (string name)
 Checks if a given name is used by a registered Option. More...
 
void Clear ()
 Clears any field and registered member's fields that may be modified once the launch arguments are parsed. More...
 

Public Attributes

readonly string Description
 Description as shown in the help text.
May be left as null. More...
 
readonly string Name
 Name used when searching for a sub-Verb or rendering the help text.
May be left as null if it has no parent and is the root. More...
 
readonly List< OptionOptions
 List of Option registered via the Verb.RegisterOption function. More...
 
readonly List< VerbVerbs
 List of sub-Verb registered via the Verb.RegisterVerb function. More...
 
Verb ParentVerb
 Reference to a potential parent Verb in which this one was registered.
May be left as null to indicate that it has no parent and is the root. More...
 
bool WasUsed
 Flag used to indicate if the Verb was used at any point during the parsing process. More...
 

Detailed Description

Class Verb models a verb that can be given in launch arguments to select a specific action or subset of usable launch parameters.

Constructor & Destructor Documentation

◆ Verb()

NibblePoker.Library.Arguments.Verb.Verb ( string  name,
string  description = "" 
)
inline

Constructs an independant Verb with the given parameters.

Parameters
nameName used when searching for a sub-Verb or rendering the help text.
descriptionDescription as shown in the help text.

Member Function Documentation

◆ Clear()

void NibblePoker.Library.Arguments.Verb.Clear ( )
inline

Clears any field and registered member's fields that may be modified once the launch arguments are parsed.

See also
NibblePoker.Library.Arguments.Option.Clear

◆ GetOptionByName()

Option NibblePoker.Library.Arguments.Verb.GetOptionByName ( string  name)
inline

Attempts to retrieve a registered Option using its name.

Parameters
nameThe desired Option's name
Returns
The relevant Option, null otherwise.

◆ GetOptionByToken()

Option NibblePoker.Library.Arguments.Verb.GetOptionByToken ( char  token)
inline

Attempts to retrieve a registered Option using its token.

Parameters
tokenThe desired Option's token
Returns
The relevant Option, null otherwise.

◆ GetRelevantDefaultOption()

Option NibblePoker.Library.Arguments.Verb.GetRelevantDefaultOption ( )
inline

Attempts to retrieve the default Option that should be used during the parsing process based on whether it has been used before.

Returns
The relevant Option, null otherwise.

◆ GetSubVerbByName()

Verb NibblePoker.Library.Arguments.Verb.GetSubVerbByName ( string  name)
inline

Attempts to retrieve a registered sub-Verb using its name.

Parameters
nameThe desired Verb's name
Returns
The relevant Verb, null otherwise.

◆ HasOptionByName()

bool NibblePoker.Library.Arguments.Verb.HasOptionByName ( string  name)
inline

Checks if a given name is used by a registered Option.

Parameters
nameThe desired Option's name
Returns
true if a matching Option was found, false otherwise.

◆ HasOptionByToken()

bool NibblePoker.Library.Arguments.Verb.HasOptionByToken ( char  token)
inline

Checks if a given token is used by a registered Option.

Parameters
tokenThe desired Option's token
Returns
true if a matching Option was found, false otherwise.

◆ RegisterOption()

Verb NibblePoker.Library.Arguments.Verb.RegisterOption ( Option  option)
inline

Attempts to register an Option in the current Verb.

Parameters
optionThe Option to register in Verb.Verbs.
Returns
Itself to allow for registration daisy-chaining.
Exceptions
Exceptions.DuplicateOptionExceptionIf the given Option or one with the same token/name is already registered.
Exceptions.ExistingDefaultMultipleOptionExceptionIf the given Option has the Default flag and is registered after one that also has OptionFlags.Default, OptionFlags.HasValue and OptionFlags.Repeatable flags.

◆ RegisterOptionRecursively()

Verb NibblePoker.Library.Arguments.Verb.RegisterOptionRecursively ( Option  option,
bool  ignoreDuplicates = false 
)
inline

Attempts to register an Option in the current Verb and all its sub-Verb in a recursive manner.

Parameters
optionThe Option to register in Verb.Verbs.
ignoreDuplicatesPrevents exceptions from being raised if an Option with the same token or name is encountered.
Default: false
Returns
Itself to allow for registration daisy-chaining.
Exceptions
Exceptions.DuplicateOptionExceptionIf the given Option or one with the same token/name is already registered.
Will not be thrown if ignoreDuplicates is set to true.
Exceptions.ExistingDefaultMultipleOptionExceptionIf the given Option has the Default flag and is registered after one that also has OptionFlags.Default, OptionFlags.HasValue and OptionFlags.Repeatable flags.

◆ RegisterVerb()

Verb NibblePoker.Library.Arguments.Verb.RegisterVerb ( Verb  verb)
inline

Attempts to register a sub-Verb in the current Verb.

Parameters
verbThe Verb to register in Verb.Verbs as a sub-Verb.
Returns
Itself to allow for registration daisy-chaining.
Exceptions
Exceptions.InvalidVerbNameExceptionIf the registered Verb's name is empty or null.
Exceptions.DuplicateVerbExceptionIf the given Verb or one with the same name is already registered.

Member Data Documentation

◆ Description

readonly string NibblePoker.Library.Arguments.Verb.Description

Description as shown in the help text.
May be left as null.

◆ Name

readonly string NibblePoker.Library.Arguments.Verb.Name

Name used when searching for a sub-Verb or rendering the help text.
May be left as null if it has no parent and is the root.

◆ Options

readonly List<Option> NibblePoker.Library.Arguments.Verb.Options

List of Option registered via the Verb.RegisterOption function.

◆ ParentVerb

Verb NibblePoker.Library.Arguments.Verb.ParentVerb

Reference to a potential parent Verb in which this one was registered.
May be left as null to indicate that it has no parent and is the root.

◆ Verbs

readonly List<Verb> NibblePoker.Library.Arguments.Verb.Verbs

List of sub-Verb registered via the Verb.RegisterVerb function.

◆ WasUsed

bool NibblePoker.Library.Arguments.Verb.WasUsed

Flag used to indicate if the Verb was used at any point during the parsing process.


The documentation for this class was generated from the following file: