rucken
Version:
Console tools and scripts for nx and not only that I (EndyKaufman) use to automate the workflow and speed up the development process
76 lines (75 loc) • 2.58 kB
TypeScript
/// <reference types="node" />
/**
* @module ConsoleService
*/
import { INestApplicationContext } from '@nestjs/common';
import * as commander from 'commander';
import { CreateCommandOptions } from './decorators';
import { CommandActionHandler, CommandActionWrapper, CommandResponse } from './interfaces';
import { EventEmitter } from 'stream';
export declare class ConsoleService {
/**
* An optional instance of the application.
* Required to scan the application
*/
protected container?: INestApplicationContext;
/**
* A Map holding group commands by name
*/
protected commands: Map<string, commander.Command>;
/**
* The root cli
*/
protected cli: commander.Command;
protected responseListener: EventEmitter;
constructor(cli: commander.Command);
static createCli(name?: string): commander.Command;
/**
* Reset the cli stack (for testing purpose only)
*/
resetCli(): void;
/**
* Get the root cli
*/
getRootCli(): commander.Command;
/**
* Get a cli
* @param name Get a cli by name, if not set, the root cli is used
*/
getCli(name?: string): commander.Command | undefined;
/**
* Set the container
*/
setContainer(container: INestApplicationContext): ConsoleService;
/**
* Get the container
*/
getContainer(): INestApplicationContext | undefined;
/**
* Wrap an action handler to work with promise.
*/
static createHandler(action: CommandActionHandler): CommandActionWrapper;
/**
* Execute the cli
*/
init(argv: string[]): Promise<CommandResponse>;
/**
* Create a Command
*
* @param options The options to create the commands
* @param handler The handler of the command
* @param parent The command to use as a parent
*/
createCommand(options: CreateCommandOptions, handler: CommandActionHandler, parent: commander.Command, commanderOptions?: commander.CommandOptions): commander.Command;
/**
* Create a group of command.
* @param options The options to create the grouped command
* @param parent The command to use as a parent
* @throws an error if the parent command contains explicit arguments, only simple commands are allowed (no spaces)
*/
createGroupCommand(options: CreateCommandOptions, parent: commander.Command): commander.Command;
/**
* Get the full name of a command (parents names + command names separated by dot)
*/
getCommandFullName(command: commander.Command): string;
}