scmJS docs

api.commands

CommandsApi

Named things a plugin can do, so a menu item, a hotkey, a context entry and another plugin all reach the same one. menu.add, contextMenu.add and hotkeys.add take a command id in place of a run.

Members

register

register(spec: CommandSpec): Disposable;

run

run(id: string, ...args: unknown[]): unknown;

Run one, whoever registered it; the command's own return value, or undefined when there is no such command.

has

has(id: string): boolean;

list

list(): CommandInfo[];

Every command registered by every plugin.

Types

Declarations only this group names.

CommandSpecinterface

interface CommandSpec
id: string

The command's id. One without a dot is namespaced under the plugin ("paint" → "paint-plugin.paint"); one with a dot is taken as it is, so a plugin can offer a stable name others call.

title: string

What a menu or a command list should call it.

enabled?: () => boolean
run: (...args: unknown[]) => unknown

CommandInfointerface

interface CommandInfo
id: string
title: string
pluginId: string
enabled: boolean

Seen in

scmJS 0.1.0 · Generated from the repository. StarCraft and Brood War are trademarks of Blizzard Entertainment; this project ships none of their data.