#!/usr/bin/env bun import { clone } from './cmds/clone'; import { detect } from './cmds/detect'; import { processCmd } from './cmds/process'; import { info } from './cmds/info'; import { verify } from './cmds/verify'; import { exportCmd } from './cmds/export'; import { query } from './cmds/query'; const commands = { clone, detect, process: processCmd, query, q: query, // Alias for query info, verify, export: exportCmd, help() { console.log(` plcbundle - Work with PLC bundle archives USAGE: bun cli [options] COMMANDS: clone Clone bundles from a remote repository detect Detect and filter operations using a custom function process Process operations with a custom function query (q) Query operations using JMESPath or simple dot notation info Show index or bundle information verify Verify bundle integrity export Export operations from bundle help Show this help Use 'bun cli -h' for command-specific help EXAMPLES: bun cli clone --remote https://plcbundle.atscan.net bun cli detect ./examples/detect.ts --bundles 1-100 bun cli q did --simple --bundles 1-1000 bun cli query 'operation.services.*.endpoint' --bundles 1-100 bun cli process ./my-processor.ts --threads 4 bun cli info --dir ./bundles bun cli verify --bundle 42 bun cli export --bundle 1 > ops.jsonl `); }, }; // Main const [command, ...args] = process.argv.slice(2); if (!command || command === '-h' || command === '--help' || !commands[command as keyof typeof commands]) { commands.help(); process.exit(command && command !== '-h' && command !== '--help' ? 1 : 0); } await commands[command as keyof typeof commands](args);