symref
Version:
Static code checker for AI code agents (Windsurf, Cline, etc.)
54 lines • 2.05 kB
JavaScript
export class OptionParser {
static parse(args) {
const options = {
dir: process.cwd(),
project: 'tsconfig.json',
include: [],
exclude: [],
verbose: false
};
for (let i = 0; i < args.length; i++) {
const arg = args[i];
if (arg.startsWith('--')) {
const [key, value] = arg.slice(2).split('=');
switch (key) {
case 'dir':
if (!value)
throw new Error('--dirオプションには値が必要です');
options.dir = value;
break;
case 'project':
if (!value)
throw new Error('--projectオプションには値が必要です');
options.project = value;
break;
case 'include':
if (!value)
throw new Error('--includeオプションには値が必要です');
options.include = value.split(',');
break;
case 'exclude':
if (!value)
throw new Error('--excludeオプションには値が必要です');
options.exclude = value.split(',');
break;
case 'verbose':
options.verbose = true;
break;
default:
throw new Error(`不明なオプション: ${key}`);
}
}
}
return options;
}
static validate(options) {
if (!options.dir) {
throw new Error('--dirオプションは必須です');
}
if (!options.project) {
throw new Error('--projectオプションは必須です');
}
}
}
//# sourceMappingURL=OptionParser.js.map