···11+/**
22+ * Example process function for general operation processing
33+ *
44+ * Usage:
55+ * plcbundle-bun process ./examples/processor.ts
66+ */
77+88+export function process({ op, position, bundle, line }: {
99+ op: any;
1010+ position: number;
1111+ bundle: number;
1212+ line: string;
1313+}) {
1414+ // Example: Count operations by year
1515+ const year = op.createdAt.substring(0, 4);
1616+1717+ // Example: Log specific operations
1818+ if (position % 1000 === 0) {
1919+ console.log(`Bundle ${bundle}, position ${position}: ${op.did}`);
2020+ }
2121+2222+ // Example: Custom logic
2323+ if (op.operation?.alsoKnownAs?.length > 0) {
2424+ // Do something with operations that have handles
2525+ }
2626+2727+ // No need to return anything
2828+}
+5-3
src/cli.ts
···2233import { clone } from './cmds/clone';
44import { detect } from './cmds/detect';
55+import { process as processCmd } from './cmds/process';
56import { info } from './cmds/info';
67import { verify } from './cmds/verify';
78import { exportCmd } from './cmds/export';
···910const commands = {
1011 clone,
1112 detect,
1313+ process: processCmd,
1214 info,
1315 verify,
1416 export: exportCmd,
···2325COMMANDS:
2426 clone Clone bundles from a remote repository
2527 detect Detect and filter operations using a custom function
2828+ process Process operations with a custom function
2629 info Show index or bundle information
2730 verify Verify bundle integrity
2831 export Export operations from bundle
···32353336EXAMPLES:
3437 bun cli clone --remote https://plcbundle.atscan.net
3838+ bun cli detect ./examples/detect.ts --bundles 1-100
3939+ bun cli process ./my-processor.ts --threads 4
3540 bun cli info --dir ./bundles
3636- bun cli detect --detect ./examples/detect.ts
3737- bun cli detect --detect ./examples/detect.ts --bundles 1-100
3838- bun cli detect --detect ./examples/detect.ts --bundles 42 --threads 4
3941 bun cli verify --bundle 42
4042 bun cli export --bundle 1 > ops.jsonl
4143 `);