@zowe/imperative
Version:
framework for building configurable CLIs
93 lines • 3.51 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.AbstractHelpGeneratorFactory = void 0;
const expect_1 = require("../../../../expect");
/**
* The abstract help generator factory class - implemented normally by imperative to provide the help generator
* object that should be used for your CLI.
* @export
* @abstract
* @class AbstractHelpGeneratorFactory
*/
class AbstractHelpGeneratorFactory {
/**
* Creates an instance of AbstractHelpGeneratorFactory.
* @param {IHelpGeneratorFactoryParms} parms - Control parameters and inforamtion required to build help generators
* @memberof AbstractHelpGeneratorFactory
*/
constructor(parms) {
const err = "Help Generator Factory Creation Error:";
expect_1.ImperativeExpect.toNotBeNullOrUndefined(parms, `${err} No input parameters were supplied.`);
expect_1.ImperativeExpect.keysToBeDefined(parms, ["rootCommandName"], `${err} No root command name was supplied.`);
this.mParms = parms;
this.mRootCommandName = parms.rootCommandName;
// TODO - what is the default color for imperative?
this.mPrimaryHighlightColor = parms.primaryHighlightColor || "yellow";
this.mProduceMarkdown = parms.produceMarkdown == null ? false : parms.produceMarkdown;
}
/**
* Verifies the input parameters and returns the help generator instance for the command.
* @param {IHelpGeneratorParms} parms - The input parameters - see interface for details.
* @returns {IHelpGenerator}
* @memberof AbstractHelpGeneratorFactory
*/
getHelpGenerator(parms) {
const err = "Get Help Generator Parameter Error:";
expect_1.ImperativeExpect.toNotBeNullOrUndefined(parms, `${err} No parameters were supplied.`);
expect_1.ImperativeExpect.keysToBeDefined(parms, ["commandDefinition"], `${err} No command definition was supplied.`);
expect_1.ImperativeExpect.keysToBeDefined(parms, ["fullCommandTree"], `${err} The full command tree was not supplied.`);
return this.getGenerator(parms);
}
/**
* Accessor of the root command nae.
* @readonly
* @protected
* @type {string}
* @memberof AbstractHelpGeneratorFactory
*/
get rootCommandName() {
return this.mRootCommandName;
}
/**
* Accessor for the primary highlight color
* @readonly
* @protected
* @type {string}
* @memberof AbstractHelpGeneratorFactory
*/
get primaryHighlightColor() {
return this.mPrimaryHighlightColor;
}
/**
* Accessor for the produce markdown flag
* @readonly
* @protected
* @type {boolean}
* @memberof AbstractHelpGeneratorFactory
*/
get produceMarkdown() {
return this.mProduceMarkdown;
}
/**
* Accessor for the full list of parameters
* @readonly
* @protected
* @type {IHelpGeneratorFactoryParms}
* @memberof AbstractHelpGeneratorFactory
*/
get factoryParameters() {
return this.mParms;
}
}
exports.AbstractHelpGeneratorFactory = AbstractHelpGeneratorFactory;
//# sourceMappingURL=AbstractHelpGeneratorFactory.js.map