public sealed class CommandLineArgumentAttribute : Attribute
Public NotInheritable Class CommandLineArgumentAttribute
Inherits Attribute
Dim instance As CommandLineArgumentAttribute
public ref class CommandLineArgumentAttribute sealed : public Attribute
If this attribute is applied to a property, the property's type determines the argument type, and the property will be set with either the set value or the default value after parsing is complete.
If an argument was not provided on the command line, and the default value is , the property will not be set and will remain at its initial value.
If this attribute is applied to a method, that method must have one of the following signatures:
public static (void|bool|CancelMode) Method(ArgumentType value, CommandLineParser parser);
public static (void|bool|CancelMode) Method(ArgumentType value);
public static (void|bool|CancelMode) Method(CommandLineParser parser);
public static (void|bool|CancelMode) Method();
In this case, the ArgumentType type determines the type of values the argument accepts. If there is no value parameter, the argument will be a switch argument, and the method will be invoked if the switch is present, even if it was explicitly set to .
The method will be invoked as soon as the argument is parsed, before parsing the entire command line is complete.
The return type must be either Void, Boolean or CancelMode. Using Void is equivalent to returning CancelModeNone, and when using Boolean, returning is equivalent to returning CancelModeAbort.
Unlike using the CancelParsing property, canceling parsing with the return value does not automatically print the usage help when using the CommandLineParserTParseWithErrorHandling method, the CommandLineParserParseT(String, ParseOptions) method or the CommandManager class. Instead, it must be requested using by setting the CommandLineParserHelpRequested property to in the target method.
CommandLineArgumentAttribute | Initializes a new instance of the CommandLineArgumentAttribute class using the specified argument name. |
ArgumentName | Gets the name of the argument. |
CancelParsing | Gets or sets a value that indicates whether argument parsing should be canceled if this argument is encountered. |
DefaultValue | Gets or sets the default value to be assigned to the property if the argument is not supplied on the command line. |
IncludeDefaultInUsageHelp | Gets or sets a value that indicates whether the argument's default value should be shown in the usage help. |
IsHidden | Gets or sets a value that indicates whether the argument is hidden from the usage help. |
IsLong | Gets or sets a value that indicates whether the argument has a long name. |
IsPositional | Gets or sets a value that indicates that an argument is positional. |
IsRequired | Gets or sets a value indicating whether the argument is required. |
IsShort | Gets or sets a value that indicates whether the argument has a short name. |
Position | Gets or sets the relative position of a positional argument. |
ShortName | Gets or sets the argument's short name. |
TypeId | When implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute) |
Equals | Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute) |
GetHashCode | Returns the hash code for this instance. (Inherited from Attribute) |
GetType | Gets the Type of the current instance. (Inherited from Object) |
IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute) |
Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute) |
ToString | Returns a string that represents the current object. (Inherited from Object) |