{"record":{"id":"c12d223baf364482","repo":"jackwener/OpenCLI","slug":"top-by-engagement-cannot-be-combined-with-outp-c12d22","errorCode":null,"errorMessage":"--top-by-engagement cannot be combined with --output-file","messagePattern":"--top-by-engagement cannot be combined with --output-file","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/twitter/likes.js","lineNumber":212,"sourceCode":"        { name: 'username', type: 'string', positional: true, help: 'Twitter screen name (with or without @). Defaults to the logged-in user when omitted.' },\n        { name: 'limit', type: 'int', default: 20, help: 'Maximum number of liked tweets to return (default 20). Ignored when --all is set.' },\n        { name: 'all', type: 'bool', default: false, help: 'Fetch all liked-tweet pages until exhausted. Prefer --output-file for large archives.' },\n        { 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)","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/twitter/likes.js#L194-L230","documentation":"The likes CLI rejects mutually exclusive options at argument-validation time: --top-by-engagement returns a ranked top-N subset, while --output-file streams the complete archive to disk; combining them is unsupported, so ArgumentError is thrown before any fetching begins.","triggerScenarios":"Running e.g. `opencli twitter likes @jack --all --top-by-engagement 50 --output-file likes.ndjson --resume-file likes.json` — fetchAll with both an output file and a positive --top-by-engagement value.","commonSituations":"Copy-pasting flags from two different example commands; a script that appends --output-file for archiving onto an existing top-N command line.","solutions":["Drop --top-by-engagement if you want the full archive streamed to the output file.","Drop --output-file (and --resume-file) if you only want the top-N by engagement returned in memory."],"exampleFix":"// before\nopencli twitter likes @jack --all --top-by-engagement 50 --output-file likes.ndjson\n// after (pick one intent)\nopencli twitter likes @jack --all --output-file likes.ndjson --resume-file likes.json","handlingStrategy":"validation","validationCode":"const flags = ['--all', '--top-by-engagement', '50', '--output-file', 'likes.ndjson'];\nif (flags.includes('--top-by-engagement') && flags.includes('--output-file')) {\n  throw new Error('Choose either top-N ranking or file output, not both');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decide the intent first: ranked top-N (in-memory) vs full archive (output-file).","Build command lines from disjoint flag groups in scripts rather than concatenating examples.","Validate flag combos in CI wrappers that assemble opencli commands."],"tags":["cli","argument-validation","twitter","flag-conflict"],"backgroundTag":"incompatible-flags","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}