@mondaycom/apps-cli
Version:
A cli tool to manage apps (and monday-code projects) in monday.com
29 lines (28 loc) • 1.53 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 { chooseSchedulerRegionIfNeeded, getRegionFromString, regionFlag } 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,
...regionFlag,
});
DEBUG_TAG = 'scheduler_list';
async run() {
const { flags } = await this.parse(SchedulerList);
let { appId } = flags;
const { region } = flags;
const parsedRegion = getRegionFromString(region);
appId = appId ? Number(appId) : await DynamicChoicesService.chooseApp();
const selectedRegion = await chooseSchedulerRegionIfNeeded(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);
}
}