⚡ Zero-dependency plcbundle library exclusively for Bun
1import { parseArgs } from 'util';
2import { PLCBundle } from '../plcbundle';
3
4export async function info(args: string[]) {
5 if (args.includes('-h') || args.includes('--help')) {
6 console.log(`
7info - Show index or bundle information
8
9OPTIONS:
10 --dir <path> Bundle directory (default: ./)
11 --bundle <num> Show specific bundle info
12 `);
13 return;
14 }
15
16 const { values } = parseArgs({
17 args,
18 options: {
19 dir: { type: 'string', default: './' },
20 bundle: { type: 'string' },
21 },
22 strict: false,
23 });
24
25 const dir = (values.dir as string) || './';
26 const bundle = new PLCBundle(dir);
27
28 if (values.bundle && typeof values.bundle === 'string') {
29 const num = parseInt(values.bundle);
30 const metadata = await bundle.getMetadata(num);
31
32 if (!metadata) {
33 console.error(`Bundle ${num} not found`);
34 process.exit(1);
35 }
36
37 console.log(JSON.stringify(metadata, null, 2));
38 } else {
39 const stats = await bundle.getStats();
40 console.log(`Version: ${stats.version}`);
41 console.log(`Last bundle: ${stats.lastBundle}`);
42 console.log(`Total bundles: ${stats.totalBundles}`);
43 console.log(`Total size: ${(stats.totalSize / 1e9).toFixed(2)} GB`);
44 console.log(`Updated: ${stats.updatedAt}`);
45 }
46}