UNPKG

polyv-live-cli

Version:

CLI tool for managing PolyV live streaming services.

40 lines 2.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.registerRobotCommands = registerRobotCommands; const robot_handler_1 = require("../handlers/robot.handler"); const errors_1 = require("../utils/errors"); const api_command_1 = require("../utils/api-command"); function withRobotHandler(program, run) { return (async () => { try { const { authConfig, serviceConfig } = await (0, api_command_1.loadApiCommandConfig)((0, api_command_1.commandParentOptions)(program)); await run(new robot_handler_1.RobotHandler(authConfig, serviceConfig)); } catch (error) { (0, errors_1.logError)(error instanceof Error ? error : new Error(String(error))); process.exit(1); } })(); } function registerRobotCommands(program) { const robotCmd = program.command('robot').description('Manage global robots'); robotCmd.command('list') .description('List global robots') .option('--page-number <page>', 'page number', api_command_1.parsePositiveInteger) .option('--page-size <size>', 'page size', api_command_1.parsePositiveInteger) .option('-o, --output <format>', 'output format (table|json)', api_command_1.validateOutputFormat, 'table') .action((options) => withRobotHandler(program, handler => handler.listRobots(options))); robotCmd.command('batch-save') .description('Batch save global robots') .requiredOption('--robots <json>', 'robots JSON array', api_command_1.parseJsonArray) .option('-f, --force', 'skip confirmation prompt') .option('-o, --output <format>', 'output format (table|json)', api_command_1.validateOutputFormat, 'table') .action((options) => withRobotHandler(program, handler => handler.batchSaveRobots(options))); robotCmd.command('batch-delete') .description('Batch delete global robots') .requiredOption('--ids <ids>', 'robot IDs, comma-separated', api_command_1.parseNumberList) .option('-f, --force', 'skip confirmation prompt') .option('-o, --output <format>', 'output format (table|json)', api_command_1.validateOutputFormat, 'table') .action((options) => withRobotHandler(program, handler => handler.batchDeleteRobots(options))); } //# sourceMappingURL=robot.commands.js.map