UNPKG

polyv-live-cli

Version:

CLI tool for managing PolyV live streaming services.

76 lines 5.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.registerMaterialCommands = registerMaterialCommands; const material_handler_1 = require("../handlers/material.handler"); const errors_1 = require("../utils/errors"); const api_command_1 = require("../utils/api-command"); function withMaterialHandler(program, run) { return (async () => { try { const { authConfig, serviceConfig } = await (0, api_command_1.loadApiCommandConfig)((0, api_command_1.commandParentOptions)(program)); await run(new material_handler_1.MaterialHandler(authConfig, serviceConfig)); } catch (error) { (0, errors_1.logError)(error instanceof Error ? error : new Error(String(error))); process.exit(1); } })(); } function registerMaterialCommands(program) { const materialCmd = program.command('material').description('Manage material library'); materialCmd.command('list') .description('List materials') .requiredOption('--type <type>', 'material type (video|image|audio|document)') .requiredOption('--page-number <page>', 'page number', api_command_1.parsePositiveInteger) .requiredOption('--page-size <size>', 'page size', api_command_1.parsePositiveInteger) .option('--category-id <id>', 'category ID', api_command_1.parsePositiveInteger) .option('--title <title>', 'title keyword') .option('--start-create-time <timestamp>', 'start create timestamp', api_command_1.parseTimestamp) .option('--end-create-time <timestamp>', 'end create timestamp', api_command_1.parseTimestamp) .option('--expire-second <seconds>', 'URL expire seconds', api_command_1.parsePositiveInteger) .option('-o, --output <format>', 'output format (table|json)', api_command_1.validateOutputFormat, 'table') .action((options) => withMaterialHandler(program, handler => handler.listMaterials(options))); materialCmd.command('delete') .description('Delete materials') .requiredOption('--material-ids <ids>', 'material IDs, comma-separated', (value) => value.split(',').map((item) => item.trim()).filter(Boolean)) .option('--delete-completely <value>', 'permanent delete flag') .option('--allow-partial-delete <value>', 'allow partial delete flag') .option('-f, --force', 'skip confirmation prompt') .option('-o, --output <format>', 'output format (table|json)', api_command_1.validateOutputFormat, 'table') .action((options) => withMaterialHandler(program, handler => handler.deleteMaterials(options))); const categoryCmd = materialCmd.command('category').description('Material category APIs'); categoryCmd.command('list') .description('List material categories') .requiredOption('--material-type <type>', 'material type') .option('--parent-id <id>', 'parent category ID', api_command_1.parsePositiveInteger) .option('-o, --output <format>', 'output format (table|json)', api_command_1.validateOutputFormat, 'table') .action((options) => withMaterialHandler(program, handler => handler.listCategories(options))); const labelCmd = materialCmd.command('label').description('Material label APIs'); labelCmd.command('list') .description('List material labels') .requiredOption('--page-number <page>', 'page number', api_command_1.parsePositiveInteger) .requiredOption('--page-size <size>', 'page size', api_command_1.parsePositiveInteger) .option('--keyword <keyword>', 'label keyword') .option('-o, --output <format>', 'output format (table|json)', api_command_1.validateOutputFormat, 'table') .action((options) => withMaterialHandler(program, handler => handler.listLabels(options))); labelCmd.command('create') .description('Create material label') .requiredOption('--name <name>', 'label name') .option('-f, --force', 'skip confirmation prompt') .option('-o, --output <format>', 'output format (table|json)', api_command_1.validateOutputFormat, 'table') .action((options) => withMaterialHandler(program, handler => handler.createLabel(options))); labelCmd.command('update') .description('Update material label') .requiredOption('--id <id>', 'label ID', api_command_1.parsePositiveInteger) .requiredOption('--name <name>', 'label name') .option('-f, --force', 'skip confirmation prompt') .option('-o, --output <format>', 'output format (table|json)', api_command_1.validateOutputFormat, 'table') .action((options) => withMaterialHandler(program, handler => handler.updateLabel(options))); labelCmd.command('delete') .description('Delete material label') .requiredOption('--id <id>', 'label ID', api_command_1.parsePositiveInteger) .option('-f, --force', 'skip confirmation prompt') .option('-o, --output <format>', 'output format (table|json)', api_command_1.validateOutputFormat, 'table') .action((options) => withMaterialHandler(program, handler => handler.deleteLabel(options))); } //# sourceMappingURL=material.commands.js.map