CommandDef
A command: a label, optional default keys, a when condition, a scope and a run function. Declared by extensions
(ExtensionInit.commands); every command is also an action of the bus (nabu.exec(id, data)).
Related guide: Commands and keymap →
Definition
import type { CommandDef } from '@aionbuilders/nabu';interface CommandDef {
confirm?: CommandConfirm;
keys?: string[];
label: string | ((ctx: CommandContext) => string);
run: (nabu: Nabu, ctx: CommandContext, data?: any) => any;
scope?: string;
when?: (ctx: CommandContext) => boolean;
}Properties
| Property | Type | Description |
|---|---|---|
confirmoptional | CommandConfirm | n/a |
keysoptional | string[] | default chords ( |
label | string | ((ctx: CommandContext) => string) | text for help, prompts, pickers |
run | (nabu: Nabu, ctx: CommandContext, data?: any) => any | a SYNCHRONOUS |
scopeoptional | string | block type the command belongs to: beats generic commands when the caret is in such a block, and limits the static conflict check to commands of the same scope |
whenoptional | (ctx: CommandContext) => boolean | where the command applies; required for a key without modifier |
Source: src/lib/utils/commands.js:45