CommandManagerGetCommandOrPossibleMatches Method

Gets the subcommand with the specified command name, or if automatic prefix aliases are enabled and there is more than one possible match, a list of possible matches.

Definition

Namespace: Ookii.CommandLine.Commands
Assembly: Ookii.CommandLine (in Ookii.CommandLine.dll) Version: 5.0.0+724ca9b7fa5edc075ec2ae65044e61b0d494fd1c
C#
public (CommandInfo Command, ImmutableArray<string?> PossibleMatches) GetCommandOrPossibleMatches(
	string commandName
)

Parameters

commandName  String
The name of the subcommand.

Return Value

ValueTupleCommandInfo, ImmutableArrayString
A tuple containing a CommandInfo instance for the specified subcommand, or if none could be found, and a list of possible matches if commandName is an ambiguous prefix alias.

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, no command is returned, but a list of possible matching command names or aliases is returned instead.

If the returned command is not , the list of possible matches will always be empty.

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