import {command, flag, help, namespace, option, param} from 'oo-cli'; import {die} from '../../lib/die'; import {formatError} from '../../lib/formatError'; import {Rivendell} from '../../lib/Rivendell'; import {applicableShards} from '../../lib/Shards'; @namespace('app') export class RegisterCommand { @param @help('The app id to reserve') public id!: string; @param @help('The display name of the app') public name!: string; @flag @help( 'Do not share this app with other developers in your organization. ' + 'If not set, the app will be shared with all developers in your organization' ) public personal: boolean = false; @option('a') @help('The availability zone that will be targeted (default: us)') private availability: string = ''; @command @help('Register an app version') public async register() { try { const shards = await applicableShards(this.availability); for (const shard of shards) { const app = await Rivendell.registerApp(this.id, this.name, this.personal, shard); console.log(`Registered app ${app.id} with name "${app.name} in ${shard}`); } } catch (e) { die(formatError(e)); } } }