import * as chalk from 'chalk'; import {command, help, namespace, option, param} from 'oo-cli'; import {die} from '../../lib/die'; import {formatError} from '../../lib/formatError'; import {Rivendell} from '../../lib/Rivendell'; @namespace('jobs') export class TriggerCommand { @param @help('The App ID (e.g. my_app)') public appId!: string; @param @help('The Job Name') public jobName!: string; @param @help('The Tracker ID to trigger the job for') public trackerId!: string; @option @help('Parameters to pass to the Job') public parameters: string = '{}'; @option('a') @help('The availability zone that will be targeted (default: us)') private availability: string = ''; @command @help('Trigger a job') public async trigger(): Promise { try { await Rivendell.triggerJob(this.appId, this.jobName, this.trackerId, this.parameters, this.availability); } catch (e: any) { die(formatError(e)); } console.log(chalk.green(`Triggered job for ${this.appId} ${this.jobName} ${this.trackerId} (${this.availability || 'us'}).`)); } }