@mablhq/mabl-cli 2.57.4 → 2.57.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9,6 +9,7 @@ const mablApiClientFactory_1 = require("../../../api/mablApiClientFactory");
|
|
|
9
9
|
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
10
10
|
const moment = require("moment");
|
|
11
11
|
const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
|
|
12
|
+
const js_yaml_1 = require("js-yaml");
|
|
12
13
|
exports.command = 'list';
|
|
13
14
|
exports.describe = 'List plans';
|
|
14
15
|
exports.builder = (yargs) => {
|
|
@@ -18,6 +19,13 @@ exports.builder = (yargs) => {
|
|
|
18
19
|
describe: 'Workspace to list plans for',
|
|
19
20
|
nargs: 1,
|
|
20
21
|
type: 'string',
|
|
22
|
+
})
|
|
23
|
+
.option(constants_1.CommandArgOutput, {
|
|
24
|
+
alias: constants_1.CommandArgAliases.OutputType,
|
|
25
|
+
default: constants_1.OutputFormats.Table,
|
|
26
|
+
describe: 'Specify result output format',
|
|
27
|
+
nargs: 1,
|
|
28
|
+
choices: [...constants_1.DefaultOutputFormatChoices, constants_1.OutputFormats.Table],
|
|
21
29
|
})
|
|
22
30
|
.option(constants_1.CommandArgLimitOutput, {
|
|
23
31
|
alias: constants_1.CommandArgAliases.LimitOutput,
|
|
@@ -31,19 +39,36 @@ exports.handler = (0, util_1.failWrapper)(listPlans);
|
|
|
31
39
|
async function listPlans(parsed) {
|
|
32
40
|
const limit = parsed.limit;
|
|
33
41
|
const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
|
|
42
|
+
const output = parsed[constants_1.CommandArgOutput];
|
|
34
43
|
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
35
44
|
const plans = await apiClient.getPlans({
|
|
36
45
|
organization_id: workspaceId,
|
|
37
46
|
limit,
|
|
38
47
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
const outputPlans = plans.map((plan) => ({
|
|
49
|
+
created_time: plan.created_time,
|
|
50
|
+
id: plan.id,
|
|
51
|
+
name: plan.name,
|
|
52
|
+
}));
|
|
53
|
+
switch (output) {
|
|
54
|
+
case constants_1.OutputFormats.Json:
|
|
55
|
+
loggingProvider_1.logger.info(JSON.stringify(outputPlans, null, 2));
|
|
56
|
+
break;
|
|
57
|
+
case constants_1.OutputFormats.Yaml:
|
|
58
|
+
loggingProvider_1.logger.info((0, js_yaml_1.dump)(outputPlans));
|
|
59
|
+
break;
|
|
60
|
+
case constants_1.OutputFormats.Table:
|
|
61
|
+
default:
|
|
62
|
+
printPlansAsTable(outputPlans);
|
|
63
|
+
loggingProvider_1.logger.info(`${outputPlans.length} plans returned`);
|
|
64
|
+
if (outputPlans.length === limit) {
|
|
65
|
+
loggingProvider_1.logger.info(`... use the --limit flag to return a larger set`);
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
43
68
|
}
|
|
44
|
-
return
|
|
69
|
+
return outputPlans.length;
|
|
45
70
|
}
|
|
46
|
-
function
|
|
71
|
+
function printPlansAsTable(plans) {
|
|
47
72
|
const table = new cli_table3_1.default({
|
|
48
73
|
head: ['ID', 'Name', 'Created time'],
|
|
49
74
|
wordWrap: true,
|