jackwener/OpenCLI · error · ArgumentError
--output-file requires --all
Error message
--output-file requires --all
What it means
--output-file only makes sense for a full multi-page archive, which requires --all; and per the follow-up check it also requires --resume-file so partial archives remain resumable. Passing --output-file without --all throws this ArgumentError.
Source
Thrown at clis/twitter/bookmarks.js:196
{ name: 'resume-file', type: 'string', help: 'Resume file for long-running all-pages bookmark 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 bookmarks 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 (saved-time) ordering. Incompatible with --output-file.' },
],
columns: ['id', 'author', 'text', 'likes', 'retweets', 'bookmarks', '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 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)');
const queryId = await resolveTwitterQueryId(page, 'Bookmarks', BOOKMARKS_QUERY_ID);
const headers = JSON.stringify({
'Authorization': `Bearer ${decodeURIComponent(TWITTER_BEARER_TOKEN)}`,
'X-Csrf-Token': ct0,
'X-Twitter-Auth-Type': 'OAuth2Session',
'X-Twitter-Active-User': 'yes',
});View on GitHub (pinned to 49907e53dc)
Solutions
- Add --all (and --resume-file) when using --output-file: `--all --resume-file r.json --output-file a.jsonl`.
- If you only want a small fetch, drop --output-file and rely on --limit.
- Check the script for a misspelled/missing --all flag.
Example fix
// before cli twitter bookmarks --output-file a.jsonl // after cli twitter bookmarks --all --resume-file r.json --output-file a.jsonl
Defensive patterns
Strategy: validation
Validate before calling
function assertArchiveFlags(args) {
const has = (f) => args.includes(f);
if (has('--output-file')) {
if (!has('--all')) throw new Error('--output-file requires --all');
if (!has('--resume-file')) throw new Error('--output-file requires --resume-file');
}
} Type guard
null
Try / catch
try {
await run(args);
} catch (e) {
if (String(e.message).includes('--output-file requires --all')) {
await run(['--all', '--resume-file', resumePath, '--output-file', outPath, ...args]);
} else throw e;
} Prevention
- Always use the full archive triple: --all --resume-file --output-file.
- Check for typos that silently disable boolean flags (e.g. `--al`).
- Lint CLI invocations in scripts with a wrapper that validates flag combos.
- Remember --output-file is only for full-page archival, not small limit-based fetches.
When it happens
Trigger: Invoking `twitter bookmarks --output-file archive.jsonl` without --all (or with --all but without --resume-file, which triggers the related '--output-file requires --resume-file' error).
Common situations: Copying an archive example but omitting --all; typo like `--al` silently not enabling fetchAll; script template drift where --all was removed.
Related errors
- archive search sort must be one of ${SORT_OPTIONS.join(', ')
- archive search mediatype must be one of ${MEDIATYPES.join(',
- archive search limit must be a positive integer
- archive search limit must be <= 100
- archive search query must not be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/61ff8708c075fcea.
Report an issue: GitHub.