Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x | import { formatTable } from '../../format-table.js';
import { defineCommand } from '../../lib/define-command.js';
import { styleText } from '../../lib/style-text.js';
import { Logger } from '../../logger.js';
import * as Addon from '../../models/addon.js';
import * as Organisation from '../../models/organisation.js';
import { humanJsonOutputFormatOption, orgaIdOrNameOption } from '../global.options.js';
export const addonListCommand = defineCommand({
description: 'List available add-ons',
since: '0.2.3',
options: {
org: orgaIdOrNameOption,
format: humanJsonOutputFormatOption,
},
args: [],
async handler(options) {
const { org: orgaIdOrName, format } = options;
const ownerId = await Organisation.getId(orgaIdOrName);
const addons = await Addon.list(ownerId);
switch (format) {
case 'json': {
const formattedAddons = addons.map((addon) => {
return {
addonId: addon.id,
creationDate: addon.creationDate,
name: addon.name,
planName: addon.plan.name,
planSlug: addon.plan.slug,
providerId: addon.provider.id,
realId: addon.realId,
region: addon.region,
type: addon.provider.name,
};
});
Logger.printJson(formattedAddons);
break;
}
case 'human':
default: {
const formattedAddons = addons.map((addon) => {
return [
addon.plan.name + ' ' + addon.provider.name,
addon.region,
styleText(['bold', 'green'], addon.name),
addon.id,
];
});
Logger.println(formatTable(formattedAddons));
}
}
},
});
|