@mondaycom/apps-cli
Version:
A cli tool to manage apps (and monday-code projects) in monday.com
34 lines (33 loc) • 1.64 kB
JavaScript
import { AuthenticatedCommand } from '../../commands-base/authenticated-command.js';
import { SchedulerBaseFlags } from '../../consts/scheduler/flags.js';
import { DynamicChoicesService } from '../../services/dynamic-choices-service.js';
import { SchedulerService } from '../../services/scheduler-service.js';
import { printJobs } from '../../services/scheduler-service.utils.js';
import logger from '../../utils/logger.js';
import { chooseRegionIfNeeded, getRegionFromString } from '../../utils/region.js';
export default class SchedulerList extends AuthenticatedCommand {
static description = 'List all scheduler jobs for an app';
static examples = ['<%= config.bin %> <%= command.id %> -a APP_ID'];
static flags = SchedulerList.serializeFlags({
appId: SchedulerBaseFlags.appId,
});
DEBUG_TAG = 'scheduler_list';
async run() {
const { flags } = await this.parse(SchedulerList);
let { appId } = flags;
const { region } = flags;
const parsedRegion = getRegionFromString(region);
try {
appId = appId ? Number(appId) : await DynamicChoicesService.chooseApp();
const selectedRegion = await chooseRegionIfNeeded(parsedRegion, { appId });
logger.debug(`Listing scheduler jobs for appId: ${appId}`, this.DEBUG_TAG);
this.preparePrintCommand(this, { appId, region: selectedRegion });
const jobs = await SchedulerService.listJobs(appId, selectedRegion);
printJobs(jobs);
}
catch (error) {
logger.debug(error, this.DEBUG_TAG);
process.exit(1);
}
}
}