CommandManagerGetCommand Method

Gets the subcommand with the specified command name.

Definition

Namespace: Ookii.CommandLine.Commands
Assembly: Ookii.CommandLine (in Ookii.CommandLine.dll) Version: 4.0.0+bb7ed9a8fdfd1cb21824750a8cf508863ad15086
C#
public CommandInfo? GetCommand(
	string commandName
)

Parameters

commandName  String
The name of the subcommand.

Return Value

CommandInfo
A CommandInfo instance for the specified subcommand, or if none could be found.

Remarks

The command is located by searching all types in the assemblies for a command type whose command name or alias matches the specified name. If there are multiple commands with the same name, the first matching one will be returned.

If the CommandOptionsAutoCommandPrefixAliases property is , this function will also return a command whose name or alias starts with commandName. In this case, the command will only be returned if there is exactly one matching command; if the prefix is ambiguous, is returned.

A command's name is taken from the CommandAttributeCommandName property. If that property is , the name is determined by taking the command type's name, and applying the transformation specified by the CommandOptionsCommandNameTransform property. A command's aliases are specified using the AliasAttribute attribute.

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 commandName 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.

Exceptions

ArgumentNullExceptioncommandName is .

See Also