fix: harden consult argument parsing

This commit is contained in:
Affaan Mustafa
2026-04-30 07:09:47 -04:00
committed by Affaan Mustafa
parent 9a3f72712b
commit 08d6c82989
2 changed files with 21 additions and 4 deletions

View File

@@ -48,6 +48,13 @@ function runTests() {
assert.match(result.stdout, /node scripts\/consult\.js "security reviews"/);
})) passed++; else failed++;
if (test('shows help even when other flags would be invalid', () => {
const result = run(['--help', '--target', 'not-a-target']);
assert.strictEqual(result.status, 0, result.stderr);
assert.match(result.stdout, /Consult ECC install components/);
})) passed++; else failed++;
if (test('recommends security components and profile for a natural language query', () => {
const result = run(['security', 'reviews', '--json']);
@@ -108,6 +115,13 @@ function runTests() {
assert.match(result.stderr, /Unknown install target/);
})) passed++; else failed++;
if (test('rejects flag-like target values as missing target names', () => {
const result = run(['security', '--target', '--json']);
assert.strictEqual(result.status, 1);
assert.match(result.stderr, /Missing value for --target/);
})) passed++; else failed++;
console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);
process.exit(failed > 0 ? 1 : 0);
}