import { Command } from "https://dotland.deno.dev/x/lume@v2.4.2/deps/cliffy.ts";
Type Parameters
Properties
Methods
Execute command.
Parse command-line arguments.
Set command callback method.
Don't throw an error if the command was called without arguments.
Set command arguments:
requiredArg:string [optionalArg: number] [...restArgs:string]
Add new sub-command.
Add new sub-command.
Add new sub-command.
Register command specific custom type.
Set default command. The default command is executed when the program was called without any argument and if no action handler is registered.
Set the long command description.
Add new environment variable.
Get arguments definition. E.g: input-file:string output-file:string
Get base command by name or alias.
Get base environment variable by name.
Get command by name or alias.
Get global command by name or alias.
Get global environment variable by name.
Get global option from parent commands by name.
Get parent command from global executed command. Be sure, to call this method only inside an action handler. Unless this or any child command was executed, this method returns always undefined.
Get short command description. This is the first line of the description.
Enable grouping of options and set the name of the group.
All option which are added after calling the .group()
method will be
grouped in the help output. If the .group()
method can be use multiple
times to create more groups.
Checks whether a child command exists by given name or alias.
Checks whether the command has an environment variable with given name or not.
Checks whether the command has an option with given name or not.
Set command help.
Set global help option.
Same as .throwErrors()
but also prevents calling Deno.exit
after
printing help or version with the --help and --version option.
Disable inheriting global commands, options and environment variables from parent commands.
Add a new option.
Parse command line arguments and execute matched command.
Set internal command pointer to child command with given name.
Enable stop early. If enabled, all arguments starting from the first non option argument will be passed as arguments with type string to the command action handler.
For example:
command --debug-level warning server --port 80
Will result in:
- options: {debugLevel: 'warning'}
- args: ['server', '--port', '80']
Handle error. If throwErrors
is enabled the error will be thrown,
otherwise a formatted error message will be printed and Deno.exit(1)
will be called. This will also trigger registered error handlers.
Throw validation errors instead of calling Deno.exit()
to handle
validation errors manually.
A validation error is thrown when the command is wrongly used by the user. For example: If the user passes some invalid options or arguments to the command.
This has no effect for parent commands. Only for the command on which this method was called and all child commands.
Example:
try {
cmd.parse();
} catch(error) {
if (error instanceof ValidationError) {
cmd.showHelp();
Deno.exit(1);
}
throw error;
}
Register custom type.
Disable parsing arguments. If enabled the raw arguments will be passed to the action handler. This has no effect for parent or child commands. Only for the command on which this method was called.
Set command version.
Set global version option.