@clerc/plugin-completions
Version:
Clerc plugin completions
85 lines (84 loc) • 2.52 kB
text/typescript
import { Plugin } from "@clerc/core";
//#region ../../node_modules/.pnpm/@bomb.sh+tab@0.0.11_cac@6.7.14_citty@0.1.6/node_modules/@bomb.sh/tab/dist/t-Cao2EVMz.d.ts
type OptionsMap = Map<string, Option>;
type Complete = (value: string, description: string) => void;
type OptionHandler = (this: Option, complete: Complete, options: OptionsMap) => void;
type ArgumentHandler = (this: Argument, complete: Complete, options: OptionsMap) => void;
declare class Argument {
name: string;
variadic: boolean;
command: Command;
handler?: ArgumentHandler;
constructor(command: Command, name: string, handler?: ArgumentHandler, variadic?: boolean);
}
declare class Option {
value: string;
description: string;
command: Command;
handler?: OptionHandler;
alias?: string;
isBoolean?: boolean;
constructor(command: Command, value: string, description: string, handler?: OptionHandler, alias?: string, isBoolean?: boolean);
}
declare class Command {
value: string;
description: string;
options: Map<string, Option>;
arguments: Map<string, Argument>;
parent?: Command;
constructor(value: string, description: string);
option(value: string, description: string, handlerOrAlias?: OptionHandler | string, alias?: string): Command;
argument(name: string, handler?: ArgumentHandler, variadic?: boolean): this;
}
//#endregion
//#region src/index.d.ts
declare module "@clerc/core" {
interface CommandCustomOptions {
/**
* Completions options for the command.
*/
completions?: {
/**
* Whether to show the command in completions output.
*
* @default true
*/
show?: boolean;
/**
* Handler to provide custom completions for the command.
*/
handler?: (command: Command) => void;
};
}
interface FlagCustomOptions {
/**
* Completions options for the flag.
*/
completions?: {
/**
* Whether to show the flag in completions output.
*
* @default true
*/
show?: boolean;
/**
* Handler to provide custom completions for the flag.
*/
handler?: OptionHandler;
};
}
interface ParameterCustomOptions {
/**
* Completions options for the parameter.
*/
completions?: {
/**
* Handler to provide custom completions for the parameter.
*/
handler?: ArgumentHandler;
};
}
}
declare const completionsPlugin: () => Plugin;
//#endregion
export { completionsPlugin };