jackwener/OpenCLI · error · ArgumentError

Cannot use both --to and --to-fid

Error message

Cannot use both --to and --to-fid

What it means

Thrown by clis/quark/save.js when both --to and --to-fid are supplied. The destination is ambiguous (path vs folder id), so the command refuses to run with an ArgumentError rather than guessing which one to honor.

Source

Thrown at clis/quark/save.js:43

        { name: 'url', required: true, positional: true, help: 'Quark share URL or pwd_id' },
        { name: 'to', default: '', help: 'Destination folder path' },
        { name: 'to-fid', default: '', help: 'Destination folder ID (overrides --to)' },
        { name: 'fids', default: '', help: 'File IDs to save (comma-separated, from share-tree). Omit to save all.' },
        { name: 'stoken', default: '', help: 'Share token (from share-tree output, required with --fids)' },
        { name: 'passcode', default: '', help: 'Share passcode (if required)' },
        { name: 'timeout', type: 'int', required: false, default: 120, help: 'Max seconds for the overall command (default: 120)' },
    ],
    func: async (page, kwargs) => {
        const url = kwargs.url;
        const to = kwargs.to;
        const toFid = kwargs['to-fid'];
        const fids = kwargs.fids;
        const stokenArg = kwargs.stoken;
        const passcode = kwargs.passcode;
        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 pwdId = extractPwdId(url);
        const saveAll = !fids;
        let stoken;
        let fidList;
        if (saveAll) {
            stoken = stokenArg || await getToken(page, pwdId, passcode);
            fidList = [];
        }
        else {
            if (!stokenArg)
                throw new ArgumentError('--stoken is required when using --fids');
            stoken = stokenArg;
            fidList = [...new Set(fids.split(',').map(id => id.trim()).filter(Boolean))];
        }
        const targetFid = toFid || await findFolder(page, to);
        const taskId = await saveShare(page, pwdId, stoken, fidList, targetFid, saveAll);
        const result = {
            success: false,

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Remove one of the two flags, keeping either --to or --to-fid.
  2. If both values are known and you prefer precision, keep --to-fid and drop --to.
  3. Audit wrapper scripts/aliases for hardcoded destination flags that may collide with user input.

Example fix

// before
quark save $URL --to /saved --to-fid $FID
// after
quark save $URL --to-fid $FID
Defensive patterns

Strategy: validation

Validate before calling

if (to && toFid) {
  throw new Error('Pass only one of --to or --to-fid');
}

Prevention

When it happens

Trigger: A command line like quark save <url> --to /folder --to-fid abc123; wrappers that always append --to-fid while the user also passes --to.

Common situations: Combining a hand-written command with generated flags from a script or alias; migrating commands from path-style to id-style and forgetting to remove the old flag.

Related errors


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