{"record":{"id":"7c34fabeae95705e","repo":"jackwener/OpenCLI","slug":"output-file-requires-all-7c34fa","errorCode":null,"errorMessage":"--output-file requires --all","messagePattern":"--output-file requires --all","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/twitter/likes.js","lineNumber":215,"sourceCode":"        { name: 'resume-file', type: 'string', help: 'Resume file for long-running all-pages likes syncs.' },\n        { name: 'output-file', type: 'string', help: 'Write all-page results to JSONL. Requires --all and --resume-file.' },\n        { name: 'max-pages', type: 'int', help: `Optional pagination safety cap (default ${DEFAULT_MAX_PAGINATION_PAGES}; raised automatically with --all).` },\n        { 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.' },\n    ],\n    columns: ['id', 'author', 'name', 'text', 'likes', 'retweets', 'created_at', 'url', 'has_media', 'media_urls', 'media_posters'],\n    func: async (page, kwargs) => {\n        const fetchAll = Boolean(kwargs.all);\n        const limit = fetchAll ? Number.POSITIVE_INFINITY : (kwargs.limit || 20);\n        const resumeFile = resolveOptionalFilePath(kwargs['resume-file'], '--resume-file');\n        const outputFile = resolveOptionalFilePath(kwargs['output-file'], '--output-file');\n        const useOutputFile = Boolean(fetchAll && outputFile);\n        const maxPages = resolveMaxPages(kwargs, fetchAll);\n        const topByEngagement = Number(kwargs['top-by-engagement'] || 0);\n        if (useOutputFile && topByEngagement > 0) {\n            throw new ArgumentError('--top-by-engagement cannot be combined with --output-file');\n        }\n        if (outputFile && !fetchAll) {\n            throw new ArgumentError('--output-file requires --all');\n        }\n        if (resumeFile && !fetchAll) {\n            throw new ArgumentError('--resume-file requires --all');\n        }\n        if (outputFile && !resumeFile) {\n            throw new ArgumentError('--output-file requires --resume-file so partial archives remain resumable');\n        }\n        const rawUsername = String(kwargs.username ?? '').trim();\n        let username = normalizeTwitterScreenName(rawUsername);\n        if (rawUsername && !username) {\n            throw new ArgumentError('twitter likes username must be a valid Twitter/X handle', 'Example: opencli twitter likes @jack --limit 20');\n        }\n        const cookies = await page.getCookies({ url: 'https://x.com' });\n        const ct0 = cookies.find((c) => c.name === 'ct0')?.value || null;\n        if (!ct0)\n            throw new AuthRequiredError('x.com', 'Not logged into x.com (no ct0 cookie)');\n        // If no username provided, detect the logged-in user.\n        // Bridge wraps primitive page.evaluate returns as { session, data:<value> };","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/twitter/likes.js#L197-L233","documentation":"--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.","triggerScenarios":"Running `opencli twitter likes @jack --output-file likes.ndjson` (no --all flag), possibly with a --limit for a paginated partial fetch.","commonSituations":"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.","solutions":["Add --all to the command when you intend to export the complete archive to a file.","Remove --output-file if you only want a limited in-memory fetch (use --limit instead)."],"exampleFix":"// before\nopencli twitter likes @jack --output-file likes.ndjson\n// after\nopencli twitter likes @jack --all --output-file likes.ndjson --resume-file likes.json","handlingStrategy":"validation","validationCode":"if (args.includes('--output-file') && !args.includes('--all')) {\n  throw new Error('--output-file requires --all');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember file output is a full-archive feature; limited pulls stay in memory.","Keep a canonical command template: --all --output-file X --resume-file Y."],"tags":["cli","argument-validation","twitter","missing-flag"],"backgroundTag":"missing-required-flag","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}