/** * CLI command map and entry point * @generated by @constructive-io/graphql-codegen * DO NOT EDIT - changes will be overwritten */ import { CLIOptions, Inquirerer, extractFirst } from 'inquirerer'; import contextCmd from './commands/context'; import authCmd from './commands/auth'; import machineCmd from './commands/machine'; import machineMessageCmd from './commands/machine-message'; import machineSessionCmd from './commands/machine-session'; import currentDatabaseIdCmd from './commands/current-database-id'; import machinesEnrollCmd from './commands/machines-enroll'; import provisionBucketCmd from './commands/provision-bucket'; const createCommandMap: () => Record< string, ( argv: Partial>, prompter: Inquirerer, options: CLIOptions ) => Promise > = () => ({ context: contextCmd, auth: authCmd, machine: machineCmd, 'machine-message': machineMessageCmd, 'machine-session': machineSessionCmd, 'current-database-id': currentDatabaseIdCmd, 'machines-enroll': machinesEnrollCmd, 'provision-bucket': provisionBucketCmd, }); const usage = "\ncsdk \n\nCommands:\n context Manage API contexts\n auth Manage authentication\n machine machine CRUD operations\n machine-message machineMessage CRUD operations\n machine-session machineSession CRUD operations\n current-database-id currentDatabaseId\n machines-enroll machinesEnroll\n provision-bucket Reconcile an S3 bucket for a logical bucket in the database.\nRecords the request on the bucket row via RLS; the bucket's job\ntrigger then enqueues the same storage:provision_bucket job used on\nINSERT, and repeated requests collapse into one pending job. This is\nidempotent for an already-reconciled bucket; failures become GraphQL\nerrors.\n\n --help, -h Show this help message\n --version, -v Show version\n"; export const commands = async ( argv: Partial>, prompter: Inquirerer, options: CLIOptions ) => { if (argv.help || argv.h) { console.log(usage); process.exit(0); } let { first: command, newArgv } = extractFirst(argv); const commandMap = createCommandMap(); if (!command) { const answer = await prompter.prompt(argv, [ { type: 'autocomplete', name: 'command', message: 'What do you want to do?', options: Object.keys(commandMap), }, ]); command = answer.command as string; } const commandFn = commandMap[command]; if (!commandFn) { console.log(usage); console.error(`Unknown command: ${command}`); process.exit(1); } await commandFn(newArgv, prompter, options); prompter.close(); return argv; };