This repository has been archived by the owner on Nov 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
UpdateProfilesHandler.ts
52 lines (48 loc) · 2.24 KB
/
UpdateProfilesHandler.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* 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.
*
*/
import { overroteProfileMessage, profileUpdatedSuccessfullyAndPath, profileReviewMessage } from "../../../../messages";
import { Imperative } from "../../Imperative";
import { ProfilesConstants } from "../../../../profiles";
import { ICommandHandler, IHandlerParameters } from "../../../../cmd";
import { Constants } from "../../../../constants";
import { TextUtils } from "../../../../utilities";
/**
* Handler for the auto-generated update profile commands
* Allows the user to simply update an existing configuration profile
*/
export default class UpdateProfilesHandler implements ICommandHandler {
/**
* The process command handler for the "update profile" command.
* @return {Promise<ICommandResponse>}: The promise to fulfill when complete.
*/
public async process(commandParameters: IHandlerParameters): Promise<void> {
/**
* Invoke the modules profile creator.
*/
const profileType = commandParameters.definition.customize[ProfilesConstants.PROFILES_COMMAND_TYPE_KEY];
const profileSpecified: string = commandParameters.arguments[Constants.PROFILE_NAME_OPTION];
const profileUpdated = await Imperative.api.profileManager(profileType).update({
name: profileSpecified,
args: commandParameters.arguments,
merge: true
});
commandParameters.response.console.log(overroteProfileMessage.message, {
profileOption: commandParameters
.arguments[Constants.PROFILE_NAME_OPTION]
});
commandParameters.response.console.log(profileUpdatedSuccessfullyAndPath.message);
commandParameters.response.console.log(profileUpdated.path);
commandParameters.response.console.log("");
commandParameters.response.console.log(TextUtils.prettyJson(profileUpdated.profile,
undefined, undefined, "\n"));
commandParameters.response.console.log(profileReviewMessage.message);
}
}