jackwener/OpenCLI · warning · ArgumentError

direction

Error message

direction

What it means

ArgumentError (code 'ARGUMENT', exit USAGE_ERROR) from the 'nav' command: the required positional 'direction' argument must be exactly 'back' or 'forward' after trim/lowercase. The library validates this before touching the page so invalid input fails immediately with a usage hint. Like error 210, this is purely an input problem.

Source

Thrown at clis/antigravity/audit-extras.js:230

    },
});

// -------- nav --------
cli({
    site: 'antigravity',
    name: 'nav',
    access: 'write',
    description: 'Click Go Back or Go Forward (Antigravity in-app history).',
    domain: '127.0.0.1',
    strategy: Strategy.UI,
    browser: true,
    args: [
        { name: 'direction', positional: true, required: true, help: 'back or forward' },
    ],
    columns: ['Status'],
    func: async (page, kwargs) => {
        const dir = String(kwargs?.direction || '').trim().toLowerCase();
        if (dir !== 'back' && dir !== 'forward') throw new ArgumentError('direction', 'must be "back" or "forward"');
        const label = dir === 'back' ? 'Go Back' : 'Go Forward';
        const res = unwrapEvaluateResult(await page.evaluate(clickFirstScript([`button[aria-label="${label}"]`])));
        if (!res?.ok) throw new CommandExecutionError(res?.reason || `${label} click failed`, '');
        return [{ Status: `${dir} clicked` }];
    },
});

// -------- toggle-aux --------
cli({
    site: 'antigravity',
    name: 'toggle-aux',
    access: 'write',
    description: 'Toggle the Auxiliary Pane (Antigravity\'s secondary panel for code/preview).',
    domain: '127.0.0.1',
    strategy: Strategy.UI,
    browser: true,
    args: [],
    columns: ['Status'],

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run with exactly 'back' or 'forward' as the positional argument.
  2. Normalize/whitelist your script's direction value before calling the command.
  3. Quote the argument in the shell to prevent splitting or empty interpolation.
  4. Check the command's help text ('back or forward') for the accepted vocabulary.

Example fix

// before
antigravity nav previous

// after
antigravity nav back
Defensive patterns

Strategy: validation

Validate before calling

const dir = String(process.argv[3] || '').trim().toLowerCase();
if (dir !== 'back' && dir !== 'forward') {
  throw new Error(`direction must be "back" or "forward", got: ${JSON.stringify(dir)}`);
}

Type guard

function isNavDirection(v) {
  return typeof v === 'string' && ['back', 'forward'].includes(v.trim().toLowerCase());
}

Try / catch

try {
  await runCmd('antigravity nav', dir);
} catch (e) {
  if (e.code === 'ARGUMENT') {
    console.error(`Invalid direction "${dir}" — use "back" or "forward".`);
    process.exitCode = 2;
  } else throw e;
}

Prevention

When it happens

Trigger: Invoking nav with direction values like 'backward', 'b', 'fwd', 'previous', '', or a misspelled token; `dir !== 'back' && dir !== 'forward'` triggers the throw. Case and whitespace are tolerated, other synonyms are not.

Common situations: Scripts mapping browser-history concepts to wrong tokens ('prev'/'next'); empty variable interpolation in shell automation; users assuming full words like 'backward' work; aliases not being supported.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/fd0596a8f8c77ef3. Report an issue: GitHub.