1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | var g = require('strong-globalize')();
|
19 | var logger = require('apiconnect-cli-logger');
|
20 |
|
21 | function catalogFullId(server, org, catalog) {
|
22 | return 'apic-catalog://' + server + '/orgs/' + org + '/catalogs/' + catalog;
|
23 | };
|
24 |
|
25 | exports.listFormatter = function(result, orgOptions) {
|
26 | if (!Object.keys(result).length) {
|
27 | if (orgOptions.allOrganizations) {
|
28 | logger.error(g.f('No catalogs found in all organizations'));
|
29 | }
|
30 | logger.error(g.f('No catalogs found in org %s', orgOptions.organization));
|
31 | }
|
32 | result.forEach(function(catalog) {
|
33 | logger.writeln(catalogFullId(orgOptions.server, catalog.orgName, catalog.shortName));
|
34 | });
|
35 | };
|
36 |
|
37 | exports.createFormatter = function(result, options) {
|
38 | logger.writeln(g.f('Created %s:%s', options.organization, result.name));
|
39 | };
|
40 |
|
41 | exports.getFormatter = function(result, options) {
|
42 | logger.writeln(g.f('name: %s', result.shortName));
|
43 | logger.writeln(g.f('display name: %s', result.name));
|
44 | logger.writeln(g.f('organization: %s', options.organization));
|
45 | if (result.autoDeploy) {
|
46 | logger.writeln(g.f('type: development'));
|
47 | } else {
|
48 | logger.writeln(g.f('type: production'));
|
49 | }
|
50 | if (result.spaceEnabled) {
|
51 | logger.writeln(g.f('spaces: enabled'));
|
52 | } else {
|
53 | logger.writeln(g.f('spaces: disabled'));
|
54 | }
|
55 | };
|
56 |
|
57 | exports.deleteFormatter = function(catalogName, options) {
|
58 | logger.writeln(g.f('Deleted %s:%s', options.organization, catalogName));
|
59 | };
|
60 |
|
61 | exports.setFormatter = function(result, options) {
|
62 | logger.writeln(g.f('Updated catalog %s in %s', result.shortName, options.organization));
|
63 | };
|
64 |
|
65 | exports.error = function(error) {
|
66 | throw error;
|
67 | };
|