ShellCommandRunShellCommand Method (Assembly, String, String, Int32, CreateShellCommandOptions) |
Namespace: Ookii.CommandLine
public static int RunShellCommand( Assembly assembly, string? commandName, string[] args, int index, CreateShellCommandOptions options )
Exception | Condition |
---|---|
ArgumentNullException | assembly, args, or options is |
ArgumentOutOfRangeException | index does not fall inside the bounds of args. |
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 a LineWrappingTextWriter for the standard output and error streams respectively, 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 is 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.