Creates an instance of a Command.
The name of the command.
The specification object for the command.
OptionalncConfig: NixClapConfig
The NixClap configuration.
Optionalparent: Command
An optional parent command.
Array of argument information for the command or option
The count of executable sub-commands.
The total number of expected arguments (required + optional)
The name of the command or option
OptionalncThe number of required arguments
The options associated with the command.
OptionalparentThe parent command, if any.
The original specification provided for the command or option
A record of sub-command aliases.
OptionalvariadicInformation about variadic arguments, if any
Get the allowUnknownOption flag
The allowUnknownOption flag
Returns the CLI type (e.g., "command" or "option")
Indicates whether this command or option has any arguments
Indicates whether this command or option has a single argument
Indicates whether this command or option has variadic arguments
Get the verbatim arguments
The verbatim arguments
Get the number of commands, including sub commands, that has exec
Generates a help message for the command and its subcommands.
OptionalprogName: string
Optional name of the program to be included in the help message.
An array of strings representing the formatted help message.
Matches a sub-command based on the provided alias.
The alias of the sub-command to match.
An object containing the matched command's name, alias, and the command itself.
Verifies that there are no duplicate options in the command. Iterates through the options and checks each one to ensure it does not already exist. Throws an error if a duplicate option is found (unless allowDuplicateOption is enabled).
Verifies that an option with the given name does not already exist in the current command or any of its parent commands. If the option exists, an error is thrown (unless allowDuplicateOption is enabled).
The name of the option to verify.
The command from which the verification is initiated.
Represents a command in the CLI application.
Template: CommandSpec
The specification type for the command.
Remarks
This class provides methods to manage and execute CLI commands, including handling sub-commands, options, and aliases. It also includes functionality to generate help messages and verify the uniqueness of options and aliases.
Example