amaran-light-cli
Version:
Command line tool for controlling Aputure Amaran lights via WebSocket to a local Amaran desktop app.
51 lines • 2.35 kB
JavaScript
import chalk from 'chalk';
import { addStandardOptions } from '../cmdUtils.js';
export function registerQuickshot(program, deps) {
const { asyncCommand } = deps;
const quickshot = program.command('quickshot').description('Manage quickshots');
addStandardOptions(quickshot.command('list').description('List all available quickshots')).action(asyncCommand(handleQuickshotList(deps)));
addStandardOptions(quickshot.command('set <id>').description('Apply a quickshot')).action(asyncCommand(handleQuickshotSet(deps)));
}
function handleQuickshotList(deps) {
const { createController } = deps;
return async (options) => {
const controller = await createController(options.url, options.clientId, options.debug);
controller.getQuickshotList((success, message, data) => {
if (success) {
// biome-ignore lint/suspicious/noExplicitAny: API response data structure varies
const quickshots = data.data;
if (quickshots.length === 0) {
console.log(chalk.yellow('No quickshots found'));
}
else {
console.log(chalk.blue('Quickshots:'));
// biome-ignore lint/suspicious/noExplicitAny: API response data structure varies
quickshots.forEach((qs, index) => {
console.log(`${index + 1}. ${chalk.green(qs.name || 'Unnamed')} (${chalk.gray(qs.id || qs.quickshot_id)})`);
});
}
}
else {
console.error(chalk.red(`Error getting quickshot list: ${message}`));
}
controller.disconnect();
});
};
}
function handleQuickshotSet(deps) {
const { createController } = deps;
return async (id, options) => {
const controller = await createController(options.url, options.clientId, options.debug);
controller.setQuickshot(id, (success, message) => {
if (success) {
console.log(chalk.green(`Quickshot ${id} applied successfully`));
}
else {
console.error(chalk.red(`Error applying quickshot: ${message}`));
}
controller.disconnect();
});
};
}
export default registerQuickshot;
//# sourceMappingURL=quickshot.js.map