affaan-m/ECC · error · Error

Missing value for .

Error message

Missing value for ${option}.

What it means

readValue fetches the value following an option token and throws when it is missing. A value is considered missing if the next argv entry is undefined (end of input) or begins with `--` (looks like another option rather than a value). This keeps option parsing unambiguous.

Solutions

  1. Supply the value right after the option: `--cwd /abs/path`, `--terminal wezterm`.
  2. If a value genuinely starts with `--`, use its absolute path or use `--cwd="$VALUE"` style / restructure so it doesn't collide with option syntax.
  3. Check flag ordering so no option is the last token on the command line.

Example fix

// before
node open-terminal.js --terminal --launch
// after
node open-terminal.js --terminal wezterm --launch
Defensive patterns

Strategy: validation

Validate before calling

const argv = process.argv.slice(2);
const needValue = ['--terminal', '--cwd', '--executable'];
argv.forEach((t, i) => { if (needValue.includes(t) && (argv[i+1] === undefined || argv[i+1].startsWith('--'))) throw new Error(`missing value for ${t}`); });

Type guard

null

Try / catch

try {
  parseArgs(process.argv);
} catch (e) {
  if (/^Missing value for /.test(e.message)) {
    console.error(e.message, '— see --help for option usage');
  } else throw e;
}

Prevention

When it happens

Trigger: Running `open-terminal.js --cwd` with nothing after it, or `--terminal --launch` where the next token is another flag instead of the terminal name.

Common situations: Forgetting the value entirely (`--cwd` alone); values that legitimately start with `--` (e.g. a directory named `--data`) triggering the misparse; reordered flags leaving an option dangling at the end.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/0ba451fb5395af49. Report an issue: GitHub.

Appendix: source

Thrown at skills/terminal-opener/scripts/open-terminal.js:83

    );
  }
  if (!resemblesExecutablePath && /[;&|<>`$]/.test(value)) {
    throw new Error(
      'Executable must be one argv entry, not an interpolated shell command string.'
    );
  }
}

function validateArgv(argv) {
  for (const argument of argv) {
    if (argument.includes('\0')) throw new Error('Arguments must not contain NUL bytes.');
  }
}

function readValue(argv, index, option) {
  const value = argv[index + 1];
  if (value === undefined || value.startsWith('--')) {
    throw new Error(`Missing value for ${option}.`);
  }
  return value;
}

function parseArgs(argv, context = {}) {
  const env = context.env || process.env;
  const initialTerminal = env.ECC_TERMINAL || DEFAULT_TERMINAL;
  const initialCwd = context.cwd || process.cwd();
  const options = {
    argv: [],
    cwd: initialCwd,
    detect: false,
    dryRun: true,
    executable: undefined,
    help: false,
    json: false,
    mode: 'normal',
    terminal: initialTerminal,

View on GitHub (pinned to 8321021c54)