affaan-m/ECC · error · Error

Unknown argument: ${arg}

Error message

Unknown argument: ${arg}

What it means

In consult.js parseArgs(), any token that starts with '-' and is not --json, --target, --limit, --help, or -h falls through to the else-if branch `arg.startsWith('-')` and throws. This catches typos, unsupported flags, and single-dash variants of flags that expect double-dash (e.g. -limit instead of --limit). Positional arguments (query words) that don't start with '-' are fine.

Source

Thrown at scripts/consult.js:225

  for (let index = 0; index < args.length; index += 1) {
    const arg = args[index];

    if (arg === '--json') {
      parsed.json = true;
    } else if (arg === '--target') {
      if (!args[index + 1] || args[index + 1].startsWith('-')) {
        throw new Error('Missing value for --target');
      }
      parsed.target = args[index + 1];
      index += 1;
    } else if (arg === '--limit') {
      if (!args[index + 1]) {
        throw new Error('Missing value for --limit');
      }
      parsed.limit = Math.min(parsePositiveInteger(args[index + 1], '--limit'), MAX_LIMIT);
      index += 1;
    } else if (arg.startsWith('-')) {
      throw new Error(`Unknown argument: ${arg}`);
    } else {
      parsed.queryParts.push(arg);
    }
  }

  if (!SUPPORTED_INSTALL_TARGETS.includes(parsed.target)) {
    throw new Error(
      `Unknown install target: ${parsed.target}. Expected one of ${SUPPORTED_INSTALL_TARGETS.join(', ')}`
    );
  }

  parsed.query = parsed.queryParts.join(' ').trim();
  return parsed;
}

function commandFor(kind, id, target) {
  if (kind === 'profile') {
    return `npx ecc-universal install --profile ${id} --target ${target}`;

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Run `node scripts/consult.js --help` to see the four accepted flags: --json, --target, --limit, --help
  2. Check for typos in flag names
  3. Remember only the query is positional — all options require double-dash

Example fix

// before
node scripts/consult.js --verbose security reviews
// after
node scripts/consult.js --json security reviews
Defensive patterns

Strategy: validation

Validate before calling

// Pre-validate that all dash-prefixed arguments are recognized
const ACCEPTED = new Set(['--json', '--target', '--limit', '--help', '-h']);
const argv = process.argv.slice(2);
for (const arg of argv) {
  if (arg.startsWith('-') && !ACCEPTED.has(arg)) {
    console.error(`Unknown argument: ${arg}`);
    console.error('Accepted flags: --json, --target <name>, --limit <n>, --help');
    process.exit(1);
  }
}

Try / catch

try {
  const options = parseArgs(process.argv);
} catch (error) {
  if (error.message.startsWith('Unknown argument:')) {
    console.error(error.message);
    console.error('Accepted: --json, --target <name>, --limit <n>, --help');
    process.exit(2);
  }
  throw error;
}

Prevention

When it happens

Trigger: Passing a flag like --verbose or --output that is not supported; using a typo such as --targe instead of --target; passing a single-dash variant like -json instead of --json.

Common situations: Confusing this script's flags with those of another ECC script; outdated documentation referencing removed flags; shell tab-completion inserting a wrong flag.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/4037cc8e6037a04c. Report an issue: GitHub.