add yargs
This commit is contained in:
@@ -18,7 +18,7 @@ import { App, AppConfig, CreateOptions } from '../types';
|
||||
|
||||
import { CreateModule } from './utils';
|
||||
|
||||
export const app: App = { configure: new Configure() };
|
||||
export const app: App = { configure: new Configure(), commands: [] };
|
||||
|
||||
export const createApp = (options: CreateOptions) => async (): Promise<App> => {
|
||||
const { config, builder } = options;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { ModuleMetadata, PipeTransform, Type } from '@nestjs/common';
|
||||
import { NestFastifyApplication } from '@nestjs/platform-fastify';
|
||||
|
||||
import { CommandModule } from 'yargs';
|
||||
|
||||
import { Configure } from '../config/configure';
|
||||
import { ConfigStorageOption, ConfigureFactory } from '../config/types';
|
||||
|
||||
@@ -8,6 +10,8 @@ export type App = {
|
||||
container?: NestFastifyApplication;
|
||||
|
||||
configure: Configure;
|
||||
|
||||
commands: CommandModule<RecordAny, RecordAny>[];
|
||||
};
|
||||
|
||||
export interface CreateOptions {
|
||||
@@ -61,3 +65,17 @@ export interface PanicOption {
|
||||
|
||||
exit?: boolean;
|
||||
}
|
||||
|
||||
export interface CommandOption<T = RecordAny, P = RecordAny> extends CommandModule<T, P> {
|
||||
instant?: boolean;
|
||||
}
|
||||
|
||||
export type CommandItem<T = RecordAny, P = RecordAny> = (
|
||||
app: Required<App>,
|
||||
) => Promise<CommandOption<T, P>>;
|
||||
|
||||
export type CommandCollection = Array<CommandItem<any, any>>;
|
||||
|
||||
export interface CreateOption {
|
||||
commands: () => CommandCollection;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user