CommandLineArgumentAttribute.CancelParsing Property

Gets or sets a value that indicates whether argument parsing should be canceled if this argument is encountered.

Definition

Namespace: Ookii.CommandLine
Assembly: Ookii.CommandLine (in Ookii.CommandLine.dll) Version: 4.2.0+a4d3631e4dcc0970081ed435288efdebc1325f83
C#
public CancelMode CancelParsing { get; set; }

Property Value

CancelMode
One of the values of the CancelMode enumeration.

Remarks

If this property is not CancelMode.None, the CommandLineParser will stop parsing the command line arguments after seeing this argument. The result of the operation will be null if this property is CancelMode.Abort, or an instance of the arguments class with the results up to this point if this property is CancelMode.Success. In the latter case, the ParseResult.RemainingArguments property will contain all arguments that were not parsed.

If CancelMode.Success is used, all required arguments must have a value at the point this argument is encountered, otherwise a CommandLineArgumentException is thrown.

Use the ParseResult.ArgumentName property to determine which argument caused cancellation.

If this property is CancelMode.Abort, the CommandLineParser.HelpRequested property will be automatically set to true when parsing is canceled.

It's possible to prevent cancellation when an argument has this property set by handling the CommandLineParser.ArgumentParsed event and setting the ArgumentParsedEventArgs.CancelParsing property to CancelMode.None.

See Also