#!/usr/bin/env node /** * inkreach-teable — CLI for operating inkreach-teable. * * Entry point. Sets up the global commander program and mounts command groups. */ import { Command } from 'commander'; import { version } from '../package.json'; import { pluginCommand } from './commands/plugin'; import { authCommand } from './commands/auth'; import { workflowCommand, triggerCommand, actionCommand } from './commands/workflow'; import { baseResourceCommands } from './commands/resources'; import { secretCommand, runsCommand, fireCommand, sqlCommand } from './commands/extras'; import { subscriptionCommand } from './commands/subscription'; const program = new Command(); program .name('inkreach-teable') .description( 'Operate inkreach-teable: tables, fields, records, views, and the self-built automation engine (8 triggers + 7 actions).\n' + 'Use --json for machine-readable output (agent parsing).' ) .version(`inkreach-teable ${version}`, '-v, --version'); // Global options (highest precedence over config file + env). program .option('--endpoint ', 'Backend URL (default http://localhost:3000)') .option('--token ', 'Personal Access Token') .option('--base-id ', 'Default base id') .option('--json', 'Output raw JSON for agent parsing') .option('--debug', 'Print requests/responses to stderr (verbose)'); // Command groups program.addCommand(authCommand()); program.addCommand(pluginCommand()); for (const c of baseResourceCommands()) program.addCommand(c); program.addCommand(workflowCommand()); program.addCommand(triggerCommand()); program.addCommand(actionCommand()); program.addCommand(subscriptionCommand()); program.addCommand(secretCommand()); program.addCommand(runsCommand()); program.addCommand(fireCommand()); program.addCommand(sqlCommand()); program.parseAsync(process.argv).catch((err) => { process.stderr.write(`Fatal: ${err instanceof Error ? err.message : String(err)}\n`); process.exit(1); });