Global Commands Api
GL.commands
Section titled “GL.commands”An API for adding commands to the command palette
commands.addCommand("MyPlugin", { text: "Do a thing", keywords: ["execute", "run"], hidden: () => false}, async (context) => { const choice = await context.select({ title: "Choose an option", options: [ { label: "Option 1", value: "one" }, { label: "Option 2", value: "two" } ] }); const number = await context.number({ title: "Pick a number", min: 1, max: 10, decimal: true }); const string = await context.string({ title: "Enter a string", maxLength: 20 });
console.log("User chose:", { choice, number, string });});Methods
Section titled “Methods”addCommand()
Section titled “addCommand()”addCommand(
id,options,callback): () =>void
Adds a command to the user’s command palette. Can request additional input within the callback.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
options | { hidden: () => boolean; keywords: string[]; text: string | () => string; } |
options.hidden? | () => boolean |
options.keywords? | string[] |
options.text | string | () => string |
callback | (context) => void | Promise<void> |
Returns
Section titled “Returns”Function
Returns
Section titled “Returns”void
removeCommands()
Section titled “removeCommands()”removeCommands(
id):void
Removes all commands that were added with the same id
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | string |
Returns
Section titled “Returns”void