BadScript 2
Loading...
Searching...
No Matches
CommandLine.OptionAttribute Class Referencesealed

Models an option specification. More...

Inheritance diagram for CommandLine.OptionAttribute:
CommandLine.BaseAttribute

Public Member Functions

 OptionAttribute ()
 Initializes a new instance of the CommandLine.OptionAttribute class. The default long name will be inferred from target property.
 
 OptionAttribute (string longName)
 Initializes a new instance of the CommandLine.OptionAttribute class.
 
 OptionAttribute (char shortName, string longName)
 Initializes a new instance of the CommandLine.OptionAttribute class.
 
 OptionAttribute (char shortName)
 Initializes a new instance of the CommandLine.OptionAttribute class.
 

Properties

string LongName [get]
 Gets long name of this command line option. This name is usually a single english word.
 
string ShortName [get]
 Gets a short name of this command line option, made of one character.
 
string SetName [get, set]
 Gets or sets the option's mutually exclusive set name.
 
bool FlagCounter [get, set]
 If true, this is an int option that counts how many times a flag was set (e.g. "-v -v -v" or "-vvv" would return 3). The property must be of type int (signed 32-bit integer).
 
char Separator [get, set]
 When applying attribute to System.Collections.Generic.IEnumerable<T> target properties, it allows you to split an argument and consume its content as a sequence.
 
string Group = string.Empty [get, set]
 Gets or sets the option group name. When one or more options are grouped, at least one of them should have value. Required rules are ignored.
 
- Properties inherited from CommandLine.BaseAttribute
bool Required [get, set]
 Gets or sets a value indicating whether a command line option is required.
 
int Min [get, set]
 When applied to System.Collections.Generic.IEnumerable<T> properties defines the lower range of items.
 
int Max [get, set]
 When applied to System.Collections.Generic.IEnumerable<T> properties defines the upper range of items.
 
object Default [get, set]
 Gets or sets mapped property default value.
 
string HelpText [get, set]
 Gets or sets a short description of this command line option. Usually a sentence summary.
 
string MetaValue [get, set]
 Gets or sets mapped property meta value. Usually an uppercase hint of required value type.
 
bool Hidden [get, set]
 Gets or sets a value indicating whether a command line option is visible in the help text.
 
Type ResourceType [get, set]
 Gets or sets the System.Type that contains the resources for HelpText.
 

Private Member Functions

 OptionAttribute (string shortName, string longName)
 

Private Attributes

string setName
 

Additional Inherited Members

- Package Functions inherited from CommandLine.BaseAttribute
 BaseAttribute ()
 Initializes a new instance of the CommandLine.BaseAttribute class.
 

Detailed Description

Models an option specification.

Definition at line 13 of file OptionAttribute.cs.

Constructor & Destructor Documentation

◆ OptionAttribute() [1/5]

CommandLine.OptionAttribute.OptionAttribute ( string  shortName,
string  longName 
)
private

Definition at line 17 of file OptionAttribute.cs.

18 {
19 if (shortName == null)
20 {
21 throw new ArgumentNullException("shortName");
22 }
23
24 if (longName == null)
25 {
26 throw new ArgumentNullException("longName");
27 }
28
29 ShortName = shortName;
30 LongName = longName;
31 setName = string.Empty;
32 Separator = '\0';
33 }
char Separator
When applying attribute to System.Collections.Generic.IEnumerable<T> target properties,...
string ShortName
Gets a short name of this command line option, made of one character.
string LongName
Gets long name of this command line option. This name is usually a single english word.

◆ OptionAttribute() [2/5]

CommandLine.OptionAttribute.OptionAttribute ( )

Initializes a new instance of the CommandLine.OptionAttribute class. The default long name will be inferred from target property.

Definition at line 39 of file OptionAttribute.cs.

40 : this(string.Empty, string.Empty) { }

◆ OptionAttribute() [3/5]

CommandLine.OptionAttribute.OptionAttribute ( string  longName)

Initializes a new instance of the CommandLine.OptionAttribute class.

Parameters
longNameThe long name of the option.

Definition at line 46 of file OptionAttribute.cs.

47 : this(string.Empty, longName) { }

◆ OptionAttribute() [4/5]

CommandLine.OptionAttribute.OptionAttribute ( char  shortName,
string  longName 
)

Initializes a new instance of the CommandLine.OptionAttribute class.

Parameters
shortNameThe short name of the option.
longNameThe long name of the option or null if not used.

Definition at line 54 of file OptionAttribute.cs.

55 : this(shortName.ToOneCharString(), longName) { }

◆ OptionAttribute() [5/5]

CommandLine.OptionAttribute.OptionAttribute ( char  shortName)

Initializes a new instance of the CommandLine.OptionAttribute class.

Parameters
shortNameThe short name of the option..

Definition at line 61 of file OptionAttribute.cs.

62 : this(shortName.ToOneCharString(), string.Empty) { }

Member Data Documentation

◆ setName

string CommandLine.OptionAttribute.setName
private

Definition at line 15 of file OptionAttribute.cs.

Property Documentation

◆ FlagCounter

bool CommandLine.OptionAttribute.FlagCounter
getset

If true, this is an int option that counts how many times a flag was set (e.g. "-v -v -v" or "-vvv" would return 3). The property must be of type int (signed 32-bit integer).

Definition at line 96 of file OptionAttribute.cs.

96{ get; set; }

◆ Group

string CommandLine.OptionAttribute.Group = string.Empty
getset

Gets or sets the option group name. When one or more options are grouped, at least one of them should have value. Required rules are ignored.

Definition at line 108 of file OptionAttribute.cs.

108{ get; set; } = string.Empty;

◆ LongName

string CommandLine.OptionAttribute.LongName
get

Gets long name of this command line option. This name is usually a single english word.

Definition at line 67 of file OptionAttribute.cs.

67{ get; }

◆ Separator

char CommandLine.OptionAttribute.Separator
getset

When applying attribute to System.Collections.Generic.IEnumerable<T> target properties, it allows you to split an argument and consume its content as a sequence.

Definition at line 102 of file OptionAttribute.cs.

102{ get; set; }

◆ SetName

string CommandLine.OptionAttribute.SetName
getset

Gets or sets the option's mutually exclusive set name.

Definition at line 77 of file OptionAttribute.cs.

78 {
79 get => setName;
80 set
81 {
82 if (value == null)
83 {
84 throw new ArgumentNullException("value");
85 }
86
87 setName = value;
88 }
89 }

◆ ShortName

string CommandLine.OptionAttribute.ShortName
get

Gets a short name of this command line option, made of one character.

Definition at line 72 of file OptionAttribute.cs.

72{ get; }

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