openclaw/scripts/mantis/cli-args.mjs
2026-10-16 15:14:32 -07:00

16 lines
475 B
JavaScript

export function parseMantisCliArgs(argv) {
const args = {};
for (let index = 0; index < argv.length; index += 2) {
const key = argv[index];
if (!key?.startsWith("--")) {
throw new Error(`Unexpected argument: ${key}`);
}
const name = key.slice(2).replaceAll("-", "_");
const value = argv[index + 1];
if (!value || value.startsWith("--")) {
throw new Error(`Missing value for ${key}`);
}
args[name] = value;
}
return args;
}