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:

Parameter Type Description
command string The command ID that will be used. Use alphanumeric characters without spaces.
description string The description text to provide in the help command, and in auto-completion prompts.
flags CliFlags | null Command line flags that can be passed in.
handler CliHandler The callback handler to handle a CLI invocation.

Returns: void

Since: 1.12.2