generated from salesforcecli/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrevert.ts
57 lines (49 loc) · 2.1 KB
/
revert.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
53
54
55
56
57
/*
* Copyright (c) 2021, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { flags, SfdxCommand } from '@salesforce/command';
import { Messages, Org } from '@salesforce/core';
import Dataflow from '../../../../lib/analytics/dataflow/dataflow';
Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/analytics', 'history');
export default class Revert extends SfdxCommand {
public static description = messages.getMessage('revertCommandDescription');
public static longDescription = messages.getMessage('revertCommandLongDescription');
public static examples = [
'$ sfdx analytics:dataflow:history:revert -i <dataflowid> -y <historyid> -l <historyLabel> '
];
protected static flagsConfig = {
dataflowid: flags.id({
char: 'i',
required: true,
description: messages.getMessage('dataflowidFlagDescription'),
longDescription: messages.getMessage('dataflowidFlagLongDescription')
}),
historyid: flags.id({
char: 'y',
required: true,
description: messages.getMessage('dataflowHistoryidFlagDescription'),
longDescription: messages.getMessage('dataflowHistoryidFlagLongDescription')
}),
label: flags.string({
char: 'l',
description: messages.getMessage('revertLabelFlagDescription'),
longDescription: messages.getMessage('revertLabelFlagLongDescription')
})
};
protected static requiresUsername = true;
protected static requiresProject = false;
public async run() {
const dataflowId = this.flags.dataflowid as string;
const dataflowHistoryId = this.flags.historyid as string;
const dataflowHistoryLabel = this.flags.label as string | undefined;
const dataflow = new Dataflow(this.org as Org);
const id = await dataflow.revertToHistory(dataflowId, dataflowHistoryId, dataflowHistoryLabel);
const message = messages.getMessage('revertSuccess', [id, dataflowHistoryId]);
this.ux.log(message);
return id;
}
}