MCPcopy Index your code
hub / github.com/Doorman11991/smallcode / parseArgs

Function parseArgs

bench/diff.js:30–49  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

28// ─── arg parsing ─────────────────────────────────────────────────────────────
29
30function parseArgs(argv) {
31 const args = { _: [], threshold: 0.02, json: false };
32 for (let i = 2; i < argv.length; i++) {
33 const a = argv[i];
34 if (a === '--threshold' || a === '-t') {
35 args.threshold = parseFloat(argv[++i]);
36 } else if (a === '--json') {
37 args.json = true;
38 } else if (a === '--help' || a === '-h') {
39 args.help = true;
40 } else if (a.startsWith('--')) {
41 console.error(`unknown flag: ${a}`);
42 process.exit(3);
43 } else {
44 args._.push(a);
45 }
46 }
47 if (!Number.isFinite(args.threshold)) args.threshold = 0.02;
48 return args;
49}
50
51function usage() {
52 console.log('Usage: node bench/diff.js <baseline> <feature> [--threshold 0.02] [--json]');

Callers 1

mainFunction · 0.70

Calls 1

errorMethod · 0.45

Tested by

no test coverage detected