@ottili/foundation-command
v1.0.13
Published
Search providers, command palette, command parser and the Ottili Workbench (SoT §8.8, §20, §21).
Readme
@ottili/foundation-command
Search providers, command palette, command parser and the Ottili Workbench (SoT §8.8, §20, §21).
Install
npm install @ottili/foundation-commandThis package is part of the Ottili Foundation Framework. See docs/OTTILI_FOUNDATION_FRAMEWORK_SOURCE_OF_TRUTH.md for the canonical spec.
Public API
CommandPaletteandusePaletteShortcutfor global search and command invocation.Workbench,WorkbenchPanelRegistry, andresolvePanelsfor the bottom workbench.tokenize,parseTokens,resolveCommand, andvalidateArgumentsfor the Workbench command parser.SearchProviderRegistry,planProvider, andmergeAndRankfor federated search.
Usage
import { tokenize, parseTokens, resolveCommand } from "@ottili/foundation-command";
import type { FoundationCommand } from "@ottili/foundation-contracts";
const input = "hq deal create --customer cus_123 --value 5000";
const tokens = tokenize(input);
const parsed = parseTokens(tokens, 3); // depth: hq deal create
const commands: FoundationCommand[] = [];
const result = resolveCommand(input, { list: () => commands });
if (result.ok) {
// result.command and result.parsed
}