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.Option Class Reference

Class Option models an option linked to one or more Verb that can be given in launch arguments to pass a value or toggle some behaviour/actions. More...

Public Member Functions

 Option (char? token, string name, string description="", OptionFlags flags=OptionFlags.None)
 Common constructor for any Option. More...
 
bool HasToken ()
 Checks if the Option has a token character. More...
 
bool HasName ()
 Checks if the Option has a name string. More...
 
string GetFullName (bool addTicks=false)
 Retrieve a proper and safe to print name representation for the Option. More...
 
bool IsDefault ()
 Checks if the Option was given the OptionFlags.Default flag in its constructor. More...
 
bool CanHaveValue ()
 Checks if the Option was given the OptionFlags.HasValue flag in its constructor. More...
 
bool IsRepeatable ()
 Checks if the Option was given the OptionFlags.Repeatable flag in its constructor. More...
 
bool CanHaveMultipleValue ()
 Checks if the Option was given the OptionFlags.HasValue and OptionFlags.Repeatable flags in its constructor. More...
 
bool IsHidden ()
 Checks if the Option was given the OptionFlags.Hidden flag in its constructor. More...
 
bool IsRequired ()
 Checks if the Option was given the OptionFlags.Required flag in its constructor. More...
 
bool ShouldStopParsing ()
 Checks if the Option was given the OptionFlags.StopsParsing flag in its constructor. More...
 
bool AllowsVerbsAfter ()
 Checks if the Option was given the OptionFlags.AllowVerbsAfter flag in its constructor. More...
 
bool HasValue ()
 Checks if the Option was used and received a value during the parsing process. More...
 
bool WasUsed ()
 Checks if the Option was used in the parsed launch arguments. More...
 
void Clear ()
 Clears any field that may be modified once the launch arguments are parsed. More...
 

Public Attributes

readonly List< string > Arguments
 List of values given to the Option if it is allowed to have any.
If it isn't allowed to hold any, the list will just be instantiated and empty. More...
 
readonly string Description
 Description as shown in the help text.
May be left as null. More...
 
readonly OptionFlags Flags
 Binary flags used to toggle some special behaviour and conditions during the parsing process. More...
 
readonly string Name
 Name string used when searching for the Option or rendering the help text.
May be left as null to indicate that it has no long name. More...
 
readonly? char Token
 Token character used when searching for the Option or rendering the help text.
May be left as null to indicate that it has no token. More...
 
int Occurrences
 Counter used to indicate how many times the Option was used during the parsing process. More...
 

Detailed Description

Class Option models an option linked to one or more Verb that can be given in launch arguments to pass a value or toggle some behaviour/actions.

Constructor & Destructor Documentation

◆ Option()

NibblePoker.Library.Arguments.Option.Option ( char?  token,
string  name,
string  description = "",
OptionFlags  flags = OptionFlags.None 
)
inline

Common constructor for any Option.

Parameters
tokenNullable token character used when searching for it in a Verb.
nameNullable name string used when searching for it in a Verb.
descriptionDescription as shown in the help text.
flagsBinary flags used to toggle some special behaviour and conditions during the parsing process.
Exceptions
Exceptions.MissingOptionIdentifierExceptionThrown is a null token and name were given.
Exceptions.InvalidFlagsExceptionThrown if some invalid OptionFlags combination was given in flags.
See also
NibblePoker.Library.Arguments.OptionFlags

Member Function Documentation

◆ AllowsVerbsAfter()

bool NibblePoker.Library.Arguments.Option.AllowsVerbsAfter ( )
inline

Checks if the Option was given the OptionFlags.AllowVerbsAfter flag in its constructor.

Returns
true if the flag was given, false otherwise.

◆ CanHaveMultipleValue()

bool NibblePoker.Library.Arguments.Option.CanHaveMultipleValue ( )
inline

Checks if the Option was given the OptionFlags.HasValue and OptionFlags.Repeatable flags in its constructor.

Returns
true if the flags were both given, false otherwise.

◆ CanHaveValue()

bool NibblePoker.Library.Arguments.Option.CanHaveValue ( )
inline

Checks if the Option was given the OptionFlags.HasValue flag in its constructor.

Returns
true if the flag was given, false otherwise.

◆ Clear()

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

Clears any field that may be modified once the launch arguments are parsed.

See also
NibblePoker.Library.Arguments.Option.Clear

◆ GetFullName()

string NibblePoker.Library.Arguments.Option.GetFullName ( bool  addTicks = false)
inline

Retrieve a proper and safe to print name representation for the Option.

Parameters
addTicksAdds the - and prefixes to the output as needed.
Returns
The name in the t, token or t|token format.
See also
NibblePoker.Library.Arguments.HelpText

◆ HasName()

bool NibblePoker.Library.Arguments.Option.HasName ( )
inline

Checks if the Option has a name string.

Returns
true if it has a name string, false otherwise.

◆ HasToken()

bool NibblePoker.Library.Arguments.Option.HasToken ( )
inline

Checks if the Option has a token character.

Returns
true if it has a token character, false otherwise.

◆ HasValue()

bool NibblePoker.Library.Arguments.Option.HasValue ( )
inline

Checks if the Option was used and received a value during the parsing process.

Returns
true if it has one or more value, false otherwise.

◆ IsDefault()

bool NibblePoker.Library.Arguments.Option.IsDefault ( )
inline

Checks if the Option was given the OptionFlags.Default flag in its constructor.

Returns
true if the flag was given, false otherwise.

◆ IsHidden()

bool NibblePoker.Library.Arguments.Option.IsHidden ( )
inline

Checks if the Option was given the OptionFlags.Hidden flag in its constructor.

Returns
true if the flag was given, false otherwise.

◆ IsRepeatable()

bool NibblePoker.Library.Arguments.Option.IsRepeatable ( )
inline

Checks if the Option was given the OptionFlags.Repeatable flag in its constructor.

Returns
true if the flag was given, false otherwise.

◆ IsRequired()

bool NibblePoker.Library.Arguments.Option.IsRequired ( )
inline

Checks if the Option was given the OptionFlags.Required flag in its constructor.

Returns
true if the flag was given, false otherwise.

◆ ShouldStopParsing()

bool NibblePoker.Library.Arguments.Option.ShouldStopParsing ( )
inline

Checks if the Option was given the OptionFlags.StopsParsing flag in its constructor.

Returns
true if the flag was given, false otherwise.

◆ WasUsed()

bool NibblePoker.Library.Arguments.Option.WasUsed ( )
inline

Checks if the Option was used in the parsed launch arguments.

Returns
true if it was used at least once, false otherwise.

Member Data Documentation

◆ Arguments

readonly List<string> NibblePoker.Library.Arguments.Option.Arguments

List of values given to the Option if it is allowed to have any.
If it isn't allowed to hold any, the list will just be instantiated and empty.

See also
NibblePoker.Library.Arguments.OptionFlags.HasValue, NibblePoker.Library.Arguments.OptionFlags.HasMultipleValue

◆ Description

readonly string NibblePoker.Library.Arguments.Option.Description

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

◆ Flags

readonly OptionFlags NibblePoker.Library.Arguments.Option.Flags

Binary flags used to toggle some special behaviour and conditions during the parsing process.

See also
NibblePoker.Library.Arguments.OptionFlags

◆ Name

readonly string NibblePoker.Library.Arguments.Option.Name

Name string used when searching for the Option or rendering the help text.
May be left as null to indicate that it has no long name.

◆ Occurrences

int NibblePoker.Library.Arguments.Option.Occurrences

Counter used to indicate how many times the Option was used during the parsing process.

See also
NibblePoker.Library.Arguments.OptionFlags.Repeatable

◆ Token

readonly? char NibblePoker.Library.Arguments.Option.Token

Token character used when searching for the Option or rendering the help text.
May be left as null to indicate that it has no token.


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