Class CommandLineOption
- Namespace
- Ubiquity.CommandLineParsing
- Assembly
- Ubiquity.CommandlineParsing.dll
Result of a single parsed command line option.
public class CommandLineOption : ICommandLineArgument
- Inheritance
-
CommandLineOption
- Implements
- Inherited Members
- Extension Methods
Constructors
CommandLineOption(string, string, string, string, CommandLineValue)
Initializes a new instance of the CommandLineOption class.
public CommandLineOption(string fullText, string switchLeader, string name, string delimiter, CommandLineValue value)
Parameters
fullText
stringFull text of the option from the command line.
switchLeader
stringThe text of the token that started the option (i.e. "-", "--", "/").
name
stringName of the option.
delimiter
stringDelimiter between the option and the value (i.e. "=" or ":").
value
CommandLineValueValue for the option.
CommandLineOption(string, string, string, CommandLineValue)
Initializes a new instance of the CommandLineOption class.
public CommandLineOption(string switchLeader, string name, string delimiter, CommandLineValue value)
Parameters
switchLeader
stringThe text of the token that started the option (i.e. "-", "--", "/").
name
stringName of the option.
delimiter
stringDelimiter between the option and the value (i.e. "=" or ":").
value
CommandLineValueValue for the option.
Properties
Delimiter
Gets the value delimiter, if any.
public string Delimiter { get; }
Property Value
- string
Delimiter parsed from the command line.
Name
Gets the name of the option this may be an empty string for parsers that allow that.
public string Name { get; }
Property Value
- string
Name of the option from the command line.
SwitchLeader
Gets the switch that introduced this option.
public string SwitchLeader { get; }
Property Value
- string
Text for the switch leader as a string.
Remarks
This allows bindings that differentiate on the switch (i.e. - vs. --) to distinguish the options. (e.g. -a and --all may represent the same option but would be parsed as distinct options).
Text
Gets the full text of argument.
public string Text { get; }
Property Value
Remarks
This is generally used for debugging and reporting errors to the user so that the actual full text of an invalid option is available to aid in clarity for the user.
For a switch/option the full text of the value includes the leading switch, the name of the option any value separator and the value. For positional arguments it includes the full string (without the outermost quotes, if any, to allow spaces, etc.. in the value).
Value
Gets the value of the option.
public CommandLineValue Value { get; }
Property Value
- CommandLineValue
Option's value or null if no value was provided.
Methods
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.