⚡ Zero-dependency plcbundle library exclusively for Bun
at main 1.7 kB view raw
1#!/usr/bin/env bun 2 3import { clone } from './cmds/clone'; 4import { detect } from './cmds/detect'; 5import { processCmd } from './cmds/process'; 6import { info } from './cmds/info'; 7import { verify } from './cmds/verify'; 8import { exportCmd } from './cmds/export'; 9import { query } from './cmds/query'; 10 11const commands = { 12 clone, 13 detect, 14 process: processCmd, 15 query, 16 q: query, // Alias for query 17 info, 18 verify, 19 export: exportCmd, 20 21 help() { 22 console.log(` 23plcbundle - Work with PLC bundle archives 24 25USAGE: 26 bun cli <command> [options] 27 28COMMANDS: 29 clone Clone bundles from a remote repository 30 detect Detect and filter operations using a custom function 31 process Process operations with a custom function 32 query (q) Query operations using JMESPath or simple dot notation 33 info Show index or bundle information 34 verify Verify bundle integrity 35 export Export operations from bundle 36 help Show this help 37 38Use 'bun cli <command> -h' for command-specific help 39 40EXAMPLES: 41 bun cli clone --remote https://plcbundle.atscan.net 42 bun cli detect ./examples/detect.ts --bundles 1-100 43 bun cli q did --simple --bundles 1-1000 44 bun cli query 'operation.services.*.endpoint' --bundles 1-100 45 bun cli process ./my-processor.ts --threads 4 46 bun cli info --dir ./bundles 47 bun cli verify --bundle 42 48 bun cli export --bundle 1 > ops.jsonl 49 `); 50 }, 51}; 52 53// Main 54const [command, ...args] = process.argv.slice(2); 55 56if (!command || command === '-h' || command === '--help' || !commands[command as keyof typeof commands]) { 57 commands.help(); 58 process.exit(command && command !== '-h' && command !== '--help' ? 1 : 0); 59} 60 61await commands[command as keyof typeof commands](args);