Click or drag to resize

ShellCommandCreateShellCommand Method (Assembly, String, String, Int32, CreateShellCommandOptions)

Finds and instantiates the shell command with the specified name, or if that fails, writes error and usage information to the specified writers.

Namespace:  Ookii.CommandLine
Assembly:  Ookii.CommandLine (in Ookii.CommandLine.dll) Version: 2.3.0
Syntax
public static ShellCommand CreateShellCommand(
	Assembly assembly,
	string commandName,
	string[] args,
	int index,
	CreateShellCommandOptions options
)

Parameters

assembly
Type: System.ReflectionAssembly
The assembly to search for the shell command.
commandName
Type: SystemString
The name of the command.
args
Type: SystemString
The arguments to the shell command.
index
Type: SystemInt32
The index in args at which to start parsing the arguments.
options
Type: Ookii.CommandLineCreateShellCommandOptions
The options to use.

Return Value

Type: ShellCommand
An instance a class deriving from ShellCommand, or if the command was not found or an error occurred parsing the arguments.
Exceptions
ExceptionCondition
ArgumentNullExceptionassembly, args, or options is
ArgumentOutOfRangeExceptionindex does not fall inside the bounds of args.
Remarks

If the command could not be found, a list of possible commands is written to Out. If an error occurs parsing the command's arguments, the error message is written to Error, and the shell command's usage information is written to Out.

If the Out property or Error property is , output is written to the standard output and error streams respectively, with line wrapping at word boundaries applied to the output, wrapping at the console's window width. When the console output is redirected to a file, Microsoft .Net will still report the console's actual window width, but on Mono the value of the WindowWidth property will be 0. In that case, the usage information will not be wrapped.

If the Out property or Error property are instance of the LineWrappingTextWriter class, this method indents additional lines for the usage syntax and argument descriptions according to the values specified by the CreateShellCommandOptions, unless the MaximumLineLength property is less than 30.

See Also