CommandManagerCreateCommand Method

Finds and instantiates the subcommand using the arguments from the EnvironmentGetCommandLineArgs method, using the first argument for the command name. If that fails, writes error and usage information.

Definition

Namespace: Ookii.CommandLine.Commands
Assembly: Ookii.CommandLine (in Ookii.CommandLine.dll) Version: 4.0.0+bb7ed9a8fdfd1cb21824750a8cf508863ad15086
C#
public ICommand? CreateCommand()

Return Value

ICommand
An instance of a class implementing the ICommand interface, or if the command was not found or an error occurred parsing the arguments.

Remarks

If the command could not be found, a list of possible commands is written using the ParseOptionsUsageWriter property. If an error occurs parsing the command's arguments, the error message is written to the stream indicated by the ParseOptionsError property, and the command's usage information is written using the ParseOptionsUsageWriter property.

If the ParseOptionsError property is , output is written to a LineWrappingTextWriter instance for the standard error stream (ConsoleError, wrapping at the console's window width. If the stream is redirected, output may still be wrapped, depending on the value returned by ConsoleWindowWidth.

Commands that don't meet the criteria of the CommandOptionsCommandFilter predicate are not returned.

If the CommandOptionsParentCommand property is , only commands without a ParentCommandAttribute attribute are returned. If it is not , only commands where the type specified using the ParentCommandAttribute attribute matches the value of the property are returned.

The automatic version command is returned if the CommandOptionsAutoVersionCommand property is and the command name matches the name of the automatic version command, and not any other command name. The CommandOptionsCommandFilter and CommandOptionsParentCommand property also affect whether the version command is returned.

See Also