Click or drag to resize

CommandLineDefineOption Method

Adds an option definition to the command line and returns the definition so its default value may be set if desired.

Namespace:  Neon.Common
Assembly:  Neon.Common (in Neon.Common.dll) Version: 2.14.0
Syntax
public CommandLineOptionDefinition DefineOption(
	params string[] names
)

Parameters

names
Type: SystemString
The option names (e.g. the short and long form).

Return Value

Type: CommandLineOptionDefinition
The CommandLineOptionDefinition.
Remarks

You can use this easily implement the short and long forms of options as well as to centralize the specification of option default values.

C#
var commandLine = new CommandLine(args);

commandLine.DefineOption("-q", "--quiet");
commandLine.DefineOption("-k", "--key").Default = "none";

// These calls both return the option value for "-q" or "--quiet".
// Since no default value was set, the default value will be the
// empty string.

commandLine.GetOption("-q");
commandLine.GetOption("--quiet");

// These calls both return the option value for "-k" or "--key".
// The default value will be "none".

commandLine.GetOption("-k");
commandLine.GetOption("--key");
See Also