@zowe/imperative
Version:
framework for building configurable CLIs
47 lines • 1.74 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.AbstractCommandBuilder = void 0;
/**
* profile.schema Command Builder - used in the module loaders to build and append additional profile.schemaside commands as
* requested by the module definition.
*/
class AbstractCommandBuilder {
/**
* Accepts an instance of this class and builds the definition and appends it to the command definition document.
* @param { AbstractCommandBuilder} builder: The builder that constructs the definition.
* @param {ICommandDefinition} definition: The definition to append to.
* command will be appended to the existing group.
*/
static appendToDocument(builder, definition) {
const actions = definition.children;
for (const child of actions) {
if (child.name === builder.getAction()) {
if (child.children) {
child.children.push(builder.build());
}
else {
child.children = [builder.build()];
}
return;
}
}
if (definition.children) {
definition.children.push(builder.buildFull());
}
else {
definition.children = [builder.buildFull()];
}
}
}
exports.AbstractCommandBuilder = AbstractCommandBuilder;
//# sourceMappingURL=AbstractCommandBuilder.js.map