Skip to content

Cli

Unofficial

Command-line interface handler for Obsidian.

Import:

import type { Cli } from '@obsidian-typings/obsidian-public-latest';

Signature:

export interface Cli

Constructor

new Cli(app: App)

Constructor.

To get the constructor instance, use getCliConstructor from obsidian-typings/implementations.

Properties

PropertyTypeDescription
appAppReference to the app.
handlersMap<string, CliHandlerEntry>Registered CLI command handlers.

Methods

MethodReturnsDescription
formatAsciiTree(nodes, prefix?)stringFormat tree nodes as an ASCII tree.
formatAsciiTreeWithRoot(root, children)stringFormat a root label and child nodes as an ASCII tree.
formatDiff(oldText, newText, oldName, newName)stringFormat two strings as a unified diff.
formatTable(headers, rows, format)stringFormat data as a table in JSON, CSV, or TSV format.
init()voidInitialize the CLI handler, registering the global handleCli function.
registerHandler(id, description, flags, handler)voidRegister a CLI command handler.
tryResolveFile(params, requireFile?)TFileTry to resolve a file from CLI input parameters.
unregisterHandler(id, handler?)voidUnregister a CLI command handler.

Links to this page: