import { red, yellow } from 'chalk'; import { CommandModule } from 'yargs'; import { undeployService, validateUndeploymentArgs } from './service-undeploy'; import { GetServiceUndeployOptions } from './service-undeploy-options'; export const serviceUndeploy: CommandModule< unknown, GetServiceUndeployOptions > = { builder: (yargs) => { return yargs .option('name', { describe: 'Name of the Deployment', alias: 'n', string: true, }) .option('serviceDeploymentId', { describe: 'ID of the Deployment', alias: 'i', string: true, }) .option('mosaicHostingClientId', { describe: 'Service Account Client ID to authenticate', alias: 'c', string: true, }) .option('mosaicHostingClientSecret', { describe: 'Service Account Client Secret to authenticate', alias: 's', string: true, }) .option('idServiceAuthBaseURL', { describe: 'ID Service Authentication Endpoint Base URL', alias: 'a', string: true, }) .option('hostingServiceBaseURL', { describe: 'Hosting Service Base URL', alias: 'h', string: true, }); }, handler: async (args) => { const [validatedArgs, errorMessages] = validateUndeploymentArgs(args); if (errorMessages.length > 0) { console.log(red('Some required arguments are missing.')); console.log(yellow(errorMessages)); console.log(); } else { await undeployService(validatedArgs); } }, };