1 | "use strict";
|
2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4 | return new (P || (P = Promise))(function (resolve, reject) {
|
5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9 | });
|
10 | };
|
11 | Object.defineProperty(exports, "__esModule", { value: true });
|
12 | exports.CommandLoader = void 0;
|
13 | const chalk = require("chalk");
|
14 | const actions_1 = require("../actions");
|
15 | const ui_1 = require("../lib/ui");
|
16 | const add_command_1 = require("./add.command");
|
17 | const build_command_1 = require("./build.command");
|
18 | const generate_command_1 = require("./generate.command");
|
19 | const info_command_1 = require("./info.command");
|
20 | const new_command_1 = require("./new.command");
|
21 | const start_command_1 = require("./start.command");
|
22 | class CommandLoader {
|
23 | static load(program) {
|
24 | return __awaiter(this, void 0, void 0, function* () {
|
25 | new new_command_1.NewCommand(new actions_1.NewAction()).load(program);
|
26 | new build_command_1.BuildCommand(new actions_1.BuildAction()).load(program);
|
27 | new start_command_1.StartCommand(new actions_1.StartAction()).load(program);
|
28 | new info_command_1.InfoCommand(new actions_1.InfoAction()).load(program);
|
29 | new add_command_1.AddCommand(new actions_1.AddAction()).load(program);
|
30 | yield new generate_command_1.GenerateCommand(new actions_1.GenerateAction()).load(program);
|
31 | this.handleInvalidCommand(program);
|
32 | });
|
33 | }
|
34 | static handleInvalidCommand(program) {
|
35 | program.on('command:*', () => {
|
36 | console.error(`\n${ui_1.ERROR_PREFIX} Invalid command: ${chalk.red('%s')}`, program.args.join(' '));
|
37 | console.log(`See ${chalk.red('--help')} for a list of available commands.\n`);
|
38 | process.exit(1);
|
39 | });
|
40 | }
|
41 | }
|
42 | exports.CommandLoader = CommandLoader;
|