CommandLineParserParseT Method (String, ParseOptions) |
Namespace: Ookii.CommandLine
Exception | Condition |
---|---|
ArgumentNullException | options is . |
ArgumentNullException | args is . |
CommandLineArgumentException | Too many positional arguments were supplied, a required argument was not supplied, an unknown argument name was supplied, no value was supplied for a named argument, an argument was supplied more than once and AllowDuplicateArguments is , or one of the argument values could not be converted to the argument's type. |
This is a convenience function that instantiates a CommandLineParser, calls Parse(String), and returns the result. If an error occurs or parsing is cancelled, it prints error and usage according to Error and Out respectively.
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.
If you want more control over the parsing process, including custom error/usage output or handling the ArgumentParsed event, do not use this function; instead perform these steps manually.