Skip to content

Function: getCommandSubCommands() ​

Get the sub-commands of a command as a normalized Map.

An array of sub-commands is keyed by the names of the commands (commandName for a lazy command). A lazy command gives the sub-commands of its definition. To read the ones that only its loader returns, resolve it first with resolveLazyCommand and needRunResolving.

Signature ​

ts
export function getCommandSubCommands<G extends GunshiParamsConstraint = DefaultGunshiParams>(cmd: Commandable<G> | Command<G> | LazyCommand<G>): Map<string, Command<G> | LazyCommand<G>> | undefined

Type Parameters ​

Name
G extends GunshiParamsConstraint = DefaultGunshiParams

Parameters ​

NameTypeDescription
cmdCommandable<G> | Command<G> | LazyCommand<G>A command or lazy command

Returns ​

Map<string, Command<G> | LazyCommand<G>> | undefined — A Map of sub-commands, or undefined if the command has no sub-commands.

Throws ​

  • TypeError — If a command in an array has no name, or two commands in an array have the same name.

Released under the MIT License.