Table of Contents

Class CommandArgument

Namespace
McMaster.Extensions.CommandLineUtils
Assembly
McMaster.Extensions.CommandLineUtils.dll

Represents one or many positional command line arguments. Arguments are parsed in the order in which Arguments lists them.

public class CommandArgument
Inheritance
object
CommandArgument
Derived
Extension Methods

Properties

DefaultValue

The default value of the argument.

public string? DefaultValue { get; set; }

Property Value

string

Description

A description of the argument.

public string? Description { get; set; }

Property Value

string

HasValue

True when Values is not empty or when a DefaultValue is given.

public bool HasValue { get; }

Property Value

bool

MultipleValues

Allow multiple values.

public bool MultipleValues { get; set; }

Property Value

bool

Name

The name of the argument.

public string? Name { get; set; }

Property Value

string

ShowInHelpText

Determines if the argument appears in the generated help-text.

public bool ShowInHelpText { get; set; }

Property Value

bool

Validators

A collection of validators that execute before invoking OnExecute(Func<int>). When validation fails, ValidationErrorHandler is invoked.

public ICollection<IArgumentValidator> Validators { get; }

Property Value

ICollection<IArgumentValidator>

Value

The first value from Values, if any, or DefaultValue.

public string? Value { get; }

Property Value

string

Values

All values specified, if any.

public IReadOnlyList<string?> Values { get; }

Property Value

IReadOnlyList<string>

Methods

Reset()

Clear any parsed values from this argument.

public virtual void Reset()

TryParse(string?)

Try to add a value to this argument.

public bool TryParse(string? value)

Parameters

value string

The argument value to be added.

Returns

bool

True if the value was accepted, false if the value cannot be added.

See Also