@zowe/imperative
Version:
framework for building configurable CLIs
88 lines • 3.83 kB
JavaScript
;
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const logger_1 = require("../../../../../logger");
const PMFConstants_1 = require("../../utilities/PMFConstants");
const utilities_1 = require("../../../../../utilities");
const error_1 = require("../../../../../error");
const PluginManagementFacility_1 = require("../../PluginManagementFacility");
/**
* The firststeps command handler for cli plugin firststeps.
*
* @see {firststepsDefinition}
*/
// export default class Handler implements ICommandHandler {
// public async process(params: IHandlerParameters): Promise<void> {
// params.response.console.log("Hello World!");
// }
// }
class FirststepsHandler {
constructor() {
/**
* A logger for this class
*
* @private
* @type {Logger}
*/
this.console = logger_1.Logger.getImperativeLogger();
}
/**
* Process the command and input.
*
* @param {IHandlerParameters} params Parameters supplied by yargs
*
* @param {string[]} [params.arguments.plugin] This is the plugin to show the first steps for.
*
* @param {IPluginCfgProps} pluginCfgProps - The configuration properties for this plugin
*
* @returns {Promise<ICommandResponse>} The command response
*
* @throws {ImperativeError}
*/
process(params) {
return __awaiter(this, void 0, void 0, function* () {
const chalk = utilities_1.TextUtils.chalk;
this.console.debug(`Root Directory: ${PMFConstants_1.PMFConstants.instance.PLUGIN_INSTALL_LOCATION}`);
if (params.arguments.plugin == null || params.arguments.plugin.length === 0) {
throw new error_1.ImperativeError({
msg: `${chalk.yellow.bold("Package name")} is required.`
});
}
else {
const pluginsProperties = PluginManagementFacility_1.PluginManagementFacility.instance.allPluginCfgProps;
for (const nextPluginCfgProps of pluginsProperties) {
if (params.arguments.plugin == nextPluginCfgProps.pluginName) {
if (nextPluginCfgProps.impConfig.pluginFirstSteps != undefined) {
params.response.console.log(nextPluginCfgProps.impConfig.pluginFirstSteps);
}
else {
params.response.console.log("The first steps are not defined for this plugin.");
}
return;
}
}
params.response.console.log("The specified plugin is not installed.");
}
});
}
}
exports.default = FirststepsHandler;
//# sourceMappingURL=showfirststeps.handler.js.map