@zowe/imperative
Version:
framework for building configurable CLIs
72 lines • 2.79 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.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImperativeHelpGeneratorFactory = void 0;
const HelpGeneratorFactory_1 = require("../../../cmd/src/help/HelpGeneratorFactory");
const AbstractHelpGeneratorFactory_1 = require("../../../cmd/src/help/abstract/AbstractHelpGeneratorFactory");
/**
* Imperative Help generator factory passed to yargs to build help generators where needed.
* @export
* @class ImperativeHelpGeneratorFactory
* @extends {AbstractHelpGeneratorFactory}
*/
class ImperativeHelpGeneratorFactory extends AbstractHelpGeneratorFactory_1.AbstractHelpGeneratorFactory {
/**
* Creates an instance of ImperativeHelpGeneratorFactory.
* @param {string} rootCommandName - The root command name of your CLI.
* @param {IImperativeConfig} config - The imperative configuration document for your CLI.
* @memberof ImperativeHelpGeneratorFactory
*/
constructor(rootCommandName, config) {
super({
produceMarkdown: false,
rootCommandName,
primaryHighlightColor: config.primaryTextColor
});
}
/**
* Obtains an instance of the help generator
* @protected
* @param {IHelpGeneratorParms} parms - See the interface for details
* @returns {IHelpGenerator} - The help generator instance
* @memberof ImperativeHelpGeneratorFactory
*/
getGenerator(parms) {
const generatorParms = {
commandDefinition: parms.commandDefinition,
fullCommandTree: parms.fullCommandTree,
experimentalCommandsDescription: parms.experimentalCommandsDescription
};
if (this.config == null) {
return new HelpGeneratorFactory_1.HelpGeneratorFactory({
produceMarkdown: this.produceMarkdown,
primaryHighlightColor: this.primaryHighlightColor,
rootCommandName: this.rootCommandName
}).getHelpGenerator(generatorParms);
}
else {
return new (require(this.config.customHelpGenerator))(generatorParms);
}
}
/**
* Internal accessor for the configuration object
* @readonly
* @private
* @type {IImperativeConfig}
* @memberof ImperativeHelpGeneratorFactory
*/
get config() {
return this.mConfig;
}
}
exports.ImperativeHelpGeneratorFactory = ImperativeHelpGeneratorFactory;
//# sourceMappingURL=ImperativeHelpGeneratorFactory.js.map