jackwener/OpenCLI · error · ArgumentError
Cannot use both --to and --to-fid
Error message
Cannot use both --to and --to-fid
What it means
quark mv rejects specifying both --to (path) and --to-fid (id) for the destination, since the two could disagree; it throws ArgumentError('Cannot use both --to and --to-fid'). Provide exactly one destination selector so the target folder is unambiguous.
Source
Thrown at clis/quark/mv.js:28
strategy: Strategy.COOKIE,
defaultFormat: 'json',
args: [
{ name: 'fids', required: true, positional: true, help: 'File IDs to move (comma-separated)' },
{ name: 'to', default: '', help: 'Destination folder path (required unless --to-fid is set)' },
{ name: 'to-fid', default: '', help: 'Destination folder ID (overrides --to)' },
{ name: 'timeout', type: 'int', required: false, default: 120, help: 'Max seconds for the overall command (default: 120)' },
],
func: async (page, kwargs) => {
const to = kwargs.to;
const toFid = kwargs['to-fid'];
const fids = kwargs.fids;
const fidList = [...new Set(fids.split(',').map(id => id.trim()).filter(Boolean))];
if (fidList.length === 0)
throw new ArgumentError('No fids provided');
if (!to && !toFid)
throw new ArgumentError('Either --to or --to-fid is required');
if (to && toFid)
throw new ArgumentError('Cannot use both --to and --to-fid');
const targetFid = toFid || await findFolder(page, to);
const data = await apiPost(page, `${DRIVE_API}/move?pr=ucpro&fr=pc`, {
filelist: fidList,
to_pdir_fid: targetFid,
});
const result = {
status: 'pending',
count: fidList.length,
destination: to || toFid,
task_id: data.task_id,
completed: false,
};
if (data.task_id) {
const completed = await pollTask(page, data.task_id);
result.completed = completed;
result.status = completed ? 'ok' : 'error';
if (!completed)
throw new CommandExecutionError('quark: Move task timed out');View on GitHub (pinned to 49907e53dc)
Solutions
- Drop --to and keep --to-fid when you already know the target folder id (faster, avoids findFolder lookup).
- Otherwise drop --to-fid and let the CLI resolve --to by folder name.
- Centralize destination selection in one config key so wrapper scripts never emit both flags.
Example fix
// before quark mv --fids fid1 --to /docs --to-fid fid_9 // after quark mv --fids fid1 --to-fid fid_9
Defensive patterns
Strategy: validation
Validate before calling
if (opts.to && opts['to-fid']) {
throw new Error('Pass only one of --to or --to-fid to quark mv');
} Type guard
function hasExactlyOneDestination(opts) {
return Boolean(opts.to) !== Boolean(opts['to-fid']);
} Try / catch
try {
await run(['quark', 'mv', '--fids', fids, ...destFlags]);
} catch (e) {
if (/Cannot use both --to and --to-fid/.test(String(e.message))) {
console.error('Drop --to and keep --to-fid (or vice versa), then retry.');
} else throw e;
} Prevention
- Source destination flags from one config key to avoid duplicates
- Prefer --to-fid in scripts; reserve --to for interactive use
- Wrapper scripts should assert flag exclusivity before exec
- Document the either/or contract where the CLI is embedded
When it happens
Trigger: Invoking quark mv with both destination flags, e.g. `quark mv --fids fid1 --to /docs --to-fid fid_9`.
Common situations: Wrapper scripts appending a default --to while the caller also passed --to-fid; copy-pasted commands combining examples; migration from path-based to id-based invocations leaving both flags in place.
Related errors
- Cannot use both --parent and --parent-fid
- No fids provided
- Either --to or --to-fid is required
- Folder name cannot be empty
- <train-no> "${trainNo}" does not look like a 12306 internal
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/c6adf9c57ad14a2f.
Report an issue: GitHub.