jackwener/OpenCLI · error · ArgumentError

--output-file requires --all

Error message

--output-file requires --all

What it means

--output-file is only supported for full-archive fetches (--all), because the streaming-to-file pipeline is built around the complete likes export. Passing --output-file without --all throws ArgumentError before any network work starts.

Source

Thrown at clis/twitter/likes.js:215

        { name: 'resume-file', type: 'string', help: 'Resume file for long-running all-pages likes syncs.' },
        { name: 'output-file', type: 'string', help: 'Write all-page results to JSONL. Requires --all and --resume-file.' },
        { name: 'max-pages', type: 'int', help: `Optional pagination safety cap (default ${DEFAULT_MAX_PAGINATION_PAGES}; raised automatically with --all).` },
        { name: 'top-by-engagement', type: 'int', default: 0, help: 'When set to N>0, re-rank the liked tweets by weighted engagement (likes×1 + retweets×3 + replies×2 + bookmarks×5 + log10(views+1)×0.5) and return the top N. Default 0 keeps the API\'s native (recency) ordering. Incompatible with --output-file.' },
    ],
    columns: ['id', 'author', 'name', 'text', 'likes', 'retweets', 'created_at', 'url', 'has_media', 'media_urls', 'media_posters'],
    func: async (page, kwargs) => {
        const fetchAll = Boolean(kwargs.all);
        const limit = fetchAll ? Number.POSITIVE_INFINITY : (kwargs.limit || 20);
        const resumeFile = resolveOptionalFilePath(kwargs['resume-file'], '--resume-file');
        const outputFile = resolveOptionalFilePath(kwargs['output-file'], '--output-file');
        const useOutputFile = Boolean(fetchAll && outputFile);
        const maxPages = resolveMaxPages(kwargs, fetchAll);
        const topByEngagement = Number(kwargs['top-by-engagement'] || 0);
        if (useOutputFile && topByEngagement > 0) {
            throw new ArgumentError('--top-by-engagement cannot be combined with --output-file');
        }
        if (outputFile && !fetchAll) {
            throw new ArgumentError('--output-file requires --all');
        }
        if (resumeFile && !fetchAll) {
            throw new ArgumentError('--resume-file requires --all');
        }
        if (outputFile && !resumeFile) {
            throw new ArgumentError('--output-file requires --resume-file so partial archives remain resumable');
        }
        const rawUsername = String(kwargs.username ?? '').trim();
        let username = normalizeTwitterScreenName(rawUsername);
        if (rawUsername && !username) {
            throw new ArgumentError('twitter likes username must be a valid Twitter/X handle', 'Example: opencli twitter likes @jack --limit 20');
        }
        const cookies = await page.getCookies({ url: 'https://x.com' });
        const ct0 = cookies.find((c) => c.name === 'ct0')?.value || null;
        if (!ct0)
            throw new AuthRequiredError('x.com', 'Not logged into x.com (no ct0 cookie)');
        // If no username provided, detect the logged-in user.
        // Bridge wraps primitive page.evaluate returns as { session, data:<value> };

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Add --all to the command when you intend to export the complete archive to a file.
  2. Remove --output-file if you only want a limited in-memory fetch (use --limit instead).

Example fix

// before
opencli twitter likes @jack --output-file likes.ndjson
// after
opencli twitter likes @jack --all --output-file likes.ndjson --resume-file likes.json
Defensive patterns

Strategy: validation

Validate before calling

if (args.includes('--output-file') && !args.includes('--all')) {
  throw new Error('--output-file requires --all');
}

Prevention

When it happens

Trigger: Running `opencli twitter likes @jack --output-file likes.ndjson` (no --all flag), possibly with a --limit for a paginated partial fetch.

Common situations: User assumes output-file works like other commands' file output for any fetch size; a shared script that always passes --output-file is used for a quick limited pull.

Related errors


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