import type { ParsedArgs } from 'minimist'; import type { ApiBlueprint } from '../blueprint/index.js'; import type { CliContext } from '../context.js'; import { type CommandDefinition, type CommandSpec } from './spec.js'; /** * One invocable command: what it looks like to help, completion, and the * interactive picker, whether it needs a login, and how to run it. Declaring * the metadata and the executor together is what keeps them from drifting. */ export interface Command { definition: CommandDefinition; /** Whether the command needs a token before it can do anything. */ requiresAuth: boolean; /** Kept out of the spec, so out of help, completion, and the picker. */ hidden?: boolean; execute: (invocation: Invocation, ctx: CliContext) => Promise; } /** Everything a single run of a command was given. */ export interface Invocation { path: string[]; /** The value written after the command path, when the command takes one. */ positional?: string | undefined; /** Params given as arguments, held to what the command accepts. */ argParams: Record; /** Params piped in as JSON, passed through as given. */ stdinParams: Record; /** The full parsed arguments, for commands that read their own flags. */ args: ParsedArgs; /** The raw argv, for commands that re-read arguments with their own types. */ argv: string[]; } export type CommandResult = { kind: 'done'; } /** Navigate back to selecting a command under `toPath`. */ | { kind: 'back'; toPath: string[]; }; export interface CommandRegistry { /** The spec help, completion, and the interactive picker render. */ spec: CommandSpec; find: (path: string[]) => Command | undefined; } export declare const localCommands: Command[]; /** Definitions shown in help, completion, and the picker. */ export declare const localCommandDefinitions: CommandDefinition[]; /** * The local command going by a path, or `undefined` when the path is an * endpoint or no command at all. Needs no blueprint, so the entry may check * commands before any definitions are loaded. */ export declare const findLocalCommand: (path: string[]) => Command | undefined; /** * The local command the given words invoke with a value after its path, e.g., * `select endpoint` for `select endpoint https://connect.getseam.com`, or * `undefined` when the words are not a command taking one. * * Only commands declaring a positional match, so a stray word after any other * command stays what it has always been: no command at all. */ export declare const findLocalCommandTakingPositional: (words: string[]) => Command | undefined; /** Parameter names a command accepts as arguments. */ export declare const acceptedParamsOf: (definition: CommandDefinition) => Set; export declare const buildRegistry: (blueprint: ApiBlueprint) => CommandRegistry;