@zowe/imperative
Version:
framework for building configurable CLIs
74 lines • 2.87 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.AuthLoginCommandBuilder = void 0;
const AuthCommandBuilder_1 = require("./AuthCommandBuilder");
const messages_1 = require("../../../../messages");
const constants_1 = require("../../../../constants");
const utilities_1 = require("../../../../utilities");
/**
* Used to build auth login command definitions.
* Used automatically if you allow the "auth" command group to be generated
*/
class AuthLoginCommandBuilder extends AuthCommandBuilder_1.AuthCommandBuilder {
/**
* Gets the "action" that this command builder is building.
* @return {string}: The "login" action string
*/
getAction() {
return constants_1.Constants.LOGIN_ACTION;
}
/**
* Build the full command - includes action group and object command.
* @return {ICommandDefinition}: The command definition.
*/
buildFull() {
return this.buildAuthSegmentFromConfig();
}
/**
* Builds only the "auth" segment from the auth config.
* @return {ICommandDefinition}
*/
buildAuthSegmentFromConfig() {
var _a, _b, _c, _d;
const authType = this.mConfig.serviceName;
const authCommand = {
name: authType,
type: "command",
summary: (_a = this.mConfig.login) === null || _a === void 0 ? void 0 : _a.summary,
description: (_b = this.mConfig.login) === null || _b === void 0 ? void 0 : _b.description,
handler: this.mConfig.handler,
options: [
{
name: "show-token", aliases: ["st"],
description: messages_1.authLoginShowTokenDesc.message,
type: "boolean"
},
...((_c = this.mConfig.login) === null || _c === void 0 ? void 0 : _c.options) || []
],
examples: (_d = this.mConfig.login) === null || _d === void 0 ? void 0 : _d.examples,
profile: {
optional: [this.mProfileType]
},
customize: {}
};
if (authCommand.summary == null) {
authCommand.summary = utilities_1.TextUtils.formatMessage(messages_1.authLoginCommandDesc.message, { type: authType });
}
if (authCommand.description == null) {
authCommand.description = authCommand.summary;
}
return authCommand;
}
}
exports.AuthLoginCommandBuilder = AuthLoginCommandBuilder;
//# sourceMappingURL=AuthLoginCommandBuilder.js.map