Home Manual Reference Source
import {CLIGenerateCommand} from 'projext/src/services/cli/cliGenerate.js'
public class | source

CLIGenerateCommand

Extends:

CLICommand → CLIGenerateCommand

This commands allows the user to generate new projext resources by makeing use of "generators", which are subclasses of CLISubCommand.

Constructor Summary

Public Constructor
public

Class constructor.

Member Summary

Public Members
public

Enable unknown options in order to pick the generator options.

public

The instruction needed to trigger the command.

public

A description of the command for the help interface.

public

A dictionary of the resource generators this command uses.

Method Summary

Public Methods
public

addGenerators(generators: Array)

Add the list of generators this command can use.

public

handle(resource: string, command: Command, options: Object, unknownOptions: Object): Promise<undefined, Error>

Handle the execution of the command and triggers the selected generator.

Inherited Summary

From class CLICommand
public

Whether or not the command supports unknown options.

public

This is a useful flag for when the command is ran as a result of another command.

public

This is the name of the program that runs the command.

public

The CLI command instruction.

public

A description of the command for the help interface.

public

A more complete description of the command to show when the command help interface is invoked.

public

Whether the command and its description should be shown on the CLI interface list of commands.

public

A list with the name of the options the command supports.

public

A dictionary of command options settings by their option name.

public

Whether or not a sub program should be executed for this command.

private

This dictionary will be completed when the command gets activated.

public

addOption(name: string, instruction: string, description: string, defaultValue: string)

Add a new option for the command.

public

Generate an instruction for this command.

public abstract

handle()

Handle the command execution.

public

output(text: string)

A simple wrapper for a console.log.

public

register(program: Command, cli: Object)

Register this command on a CLI program.

Public Constructors

public constructor() source

Class constructor.

Override:

CLICommand#constructor

Public Members

public allowUnknownOptions: boolean source

Enable unknown options in order to pick the generator options.

Override:

CLICommand#allowUnknownOptions

public command: string source

The instruction needed to trigger the command.

Override:

CLICommand#command

public description: string source

A description of the command for the help interface. Take note that this command also has a fullDescription property, but it's generated every time addGenerators gets called so the detailed description can include the generators information.

Override:

CLICommand#description

public generators: Object source

A dictionary of the resource generators this command uses. The generators are added by using the addGenerators method and they key used to save them is their resource property.

Public Methods

public addGenerators(generators: Array) source

Add the list of generators this command can use. After saving the reference to the services, this method will also update the fullDescription property with the generators information.

Params:

NameTypeAttributeDescription
generators Array

A list of CLISubCommand services.

public handle(resource: string, command: Command, options: Object, unknownOptions: Object): Promise<undefined, Error> source

Handle the execution of the command and triggers the selected generator.

Override:

CLICommand#handle

Params:

NameTypeAttributeDescription
resource string
  • nullable: true

The name of the resource that needs to be generated. It needs to match with the a generator key on the generators dictionary.

command Command

The executed command (sent by commander).

options Object

The command known options.

unknownOptions Object

A dictionary of received unkown options. this method will parse them and send them to the selected generator.

Return:

Promise<undefined, Error>