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 | 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x | import { get as getApp } from '@clevercloud/client/esm/api/v2/application.js';
import { defineCommand } from '../../lib/define-command.js';
import { Logger } from '../../logger.js';
import * as Application from '../../models/application.js';
import { getDomainObject, getFavouriteDomain } from '../../models/domain.js';
import { sendToApi } from '../../models/send-to-api.js';
import { aliasOption, appIdOrNameOption, humanJsonOutputFormatOption } from '../global.options.js';
export const domainCommand = defineCommand({
description: 'Manage domain names for an application',
since: '0.2.0',
options: {
alias: aliasOption,
app: appIdOrNameOption,
format: humanJsonOutputFormatOption,
},
args: [],
async handler(options) {
const { alias, app: appIdOrName, format } = options;
const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
const app = await getApp({ id: ownerId, appId }).then(sendToApi);
const favouriteDomain = await getFavouriteDomain({ ownerId, appId });
const domains = app.vhosts.map((vhost) => getDomainObject(vhost.fqdn, favouriteDomain));
switch (format) {
case 'json':
Logger.printJson(domains);
break;
default:
domains.forEach((domain) => {
Logger.println(`${domain.isFavourite ? '* ' : ' '}${domain.domainWithPathPrefix}`);
});
break;
}
},
});
|