@moostjs/event-cli
Version:
@moostjs/event-cli
74 lines (66 loc) • 2.57 kB
TypeScript
import { WooksCli, TWooksCliOptions } from '@wooksjs/event-cli';
export { useCliContext } from '@wooksjs/event-cli';
import * as moost from 'moost';
import { TMoostAdapter, Moost, TMoostAdapterOptions } from 'moost';
export { Controller, Description, Intercept, Optional, Param, TInterceptorPriority, defineInterceptorFn } from 'moost';
declare function Cli(path?: string): MethodDecorator;
declare function CliAlias(alias: string): MethodDecorator;
declare function CliExample(cmd: string, description?: string): MethodDecorator;
declare function CliOption(...keys: string[]): ParameterDecorator;
declare function CliGlobalOption(option: {
keys: string[];
description?: string;
value?: string;
}): ClassDecorator;
type TFunction = Function;
interface TCliHandlerMeta {
path: string;
}
interface TMoostCliOpts {
wooksCli?: WooksCli | TWooksCliOptions;
debug?: boolean;
globalCliOptions?: Array<{
keys: string[];
description?: string;
type?: TFunction;
}>;
}
declare class MoostCli implements TMoostAdapter<TCliHandlerMeta> {
protected opts?: TMoostCliOpts | undefined;
readonly name = "cli";
protected cliApp: WooksCli;
protected optionTypes: Record<string, TFunction[]>;
constructor(opts?: TMoostCliOpts | undefined);
onNotFound(): Promise<unknown>;
protected moost?: Moost;
onInit(moost: Moost): void;
bindHandler<T extends object = object>(opts: TMoostAdapterOptions<TCliHandlerMeta, T>): void;
}
declare const cliHelpInterceptor: (opts?: {
helpOptions?: string[];
colors?: boolean;
lookupLevel?: number;
}) => moost.TInterceptorFn;
declare const CliHelpInterceptor: (opts?: {
helpOptions?: string[] | undefined;
colors?: boolean | undefined;
lookupLevel?: number | undefined;
} | undefined) => ClassDecorator & MethodDecorator;
type THelpOptions = {
name?: string;
title?: string;
maxWidth?: number;
maxLeft?: number;
mark?: string;
colors?: boolean;
lookupLevel?: number;
};
declare class CliApp extends Moost {
protected _helpOpts?: THelpOptions;
protected _globalOpts?: TMoostCliOpts['globalCliOptions'];
controllers(...controllers: Array<object | Function | [string, object | Function]>): this;
useHelp(helpOpts: THelpOptions): this;
useOptions(globalOpts: TMoostCliOpts['globalCliOptions']): this;
start(): Promise<void>;
}
export { Cli, CliAlias, CliApp, CliExample, CliGlobalOption, CliHelpInterceptor, CliOption, MoostCli, type TCliHandlerMeta, type TMoostCliOpts, cliHelpInterceptor };