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 | 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 { getOwnerIdFromOrgIdOrName } from '../../models/ids-resolver.js';
import { humanJsonOutputFormatOption, orgaIdOrNameOption } from '../global.options.js';
export const addonProvidersCommand = defineCommand({
description: 'List available add-on providers',
since: '0.2.3',
options: {
org: orgaIdOrNameOption,
format: humanJsonOutputFormatOption,
},
args: [],
async handler(options) {
const { org: orgaIdOrName, format } = options;
const ownerId = await getOwnerIdFromOrgIdOrName(orgaIdOrName);
const providers = await Addon.listProviders(ownerId);
switch (format) {
case 'json': {
const formattedProviders = providers.map((provider) => ({
id: provider.id,
name: provider.name,
shortDesc: provider.shortDesc,
regions: provider.regions,
plans: provider.plans.map((plan) => ({
id: plan.id,
name: plan.name,
slug: plan.slug,
})),
}));
Logger.printJson(formattedProviders);
break;
}
case 'human':
default: {
const formattedProviders = providers.map((provider) => {
return [styleText('bold', provider.id), provider.name, provider.shortDesc || ''];
});
Logger.println(formatTable(formattedProviders));
}
}
},
});
|