public static T Parse<T>(
ParseOptions? options = null
)
where T : class
Public Shared Function Parse(Of T As Class) (
Optional options As ParseOptions = Nothing
) As T
Dim options As ParseOptions
Dim returnValue As T
returnValue = CommandLineParser.Parse(options)
public:
generic<typename T>
where T : ref class
static T Parse(
ParseOptions^ options = nullptr
)
This is a convenience function that instantiates a CommandLineParserT, calls the ParseWithErrorHandling method, and returns the result. If an error occurs or parsing is canceled, it prints errors to the ParseOptionsError stream, and usage help to the UsageWriter if the HelpRequested property is . It then returns .
If the ParseOptionsError parameter is , output is written to a LineWrappingTextWriter for the standard error stream, wrapping at the console's window width. If the stream is redirected, output may still be wrapped, depending on the value returned by ConsoleWindowWidth.
Color is applied to the output depending on the value of the UsageWriterUseColor property, the ParseOptionsUseErrorColor property, and the capabilities of the console.
If you want more control over the parsing process, including custom error/usage output or handling the ArgumentParsed event, you should use the instance CommandLineParserTParse or CommandLineParserTParseWithErrorHandling method.
This method uses reflection to determine the arguments defined by the type T at runtime, unless the type has the GeneratedParserAttribute applied. For a type using that attribute, you can also use the generated static IParserProviderTSelfCreateParser(ParseOptions) or IParserTSelfParse(ParseOptions) methods on the arguments class instead.
CommandLineArgumentException | An error occurred parsing the command line. Check the CommandLineArgumentExceptionCategory property for the exact reason for the error. |
NotSupportedException | The CommandLineParser cannot use T as the command line arguments type, because it violates one of the rules concerning argument names or positions, or has an argument type that cannot be parsed. |