Skip to content

Plugin.registerCliHandler method

Plugin › registerCliHandler

Official

Register a CLI handler to handle a command from the CLI. obsidian#Command IDs must be globally unique. Attempting to register a command that is already registered will throw an Error.

Use the format <plugin-id> for your default command, and <plugin-id>:<action> for sub-commands and actions.

Signature:

registerCliHandler(command: string, description: string, flags: CliFlags | null, handler: CliHandler): void

Parameters:

ParameterTypeDescription
commandstringThe command ID that will be used. Use alphanumeric characters without spaces.
descriptionstringThe description text to provide in the help command, and in auto-completion prompts.
flagsCliFlags | nullCommand line flags that can be passed in.
handlerCliHandlerThe callback handler to handle a CLI invocation.

Returns: void

Since: 1.12.2