jackwener/OpenCLI · error · ArgumentError

--unread and --seq are mutually exclusive

Error message

--unread and --seq are mutually exclusive

What it means

`channel-mark` treats `--unread` (mark whole channel unread) and `--seq` (mark read up to a sequence number) as mutually exclusive modes. Passing both is ambiguous, so the CLI throws ArgumentError before issuing any request.

Source

Thrown at clis/slock/channel-mark.js:33

  access: 'write',
  description: 'Mark a channel read (default), read up to --seq, or --unread.',
  domain: SLOCK_DOMAIN,
  strategy: Strategy.COOKIE,
  browser: true,
  siteSession: 'persistent',
  args: [
    { name: 'channel', positional: true, required: true, help: 'channelId UUID or #name' },
    { name: 'seq', type: 'int', help: 'Mark read up to this seq (omit for read-all)' },
    { name: 'unread', type: 'bool', default: false, help: 'Mark the channel unread instead of read' },
    { name: 'server', help: 'Override active server' },
  ],
  columns: ['channel', 'action', 'result'],
  func: async (page, kwargs) => {
    const channel = String(kwargs.channel ?? '').trim();
    if (!channel) throw new ArgumentError('channel required');
    const hasSeq = kwargs.seq !== undefined && kwargs.seq !== null && kwargs.seq !== '';
    if (kwargs.unread && hasSeq) {
      throw new ArgumentError('--unread and --seq are mutually exclusive');
    }

    let pathSuffix;
    let body;
    let action;
    if (kwargs.unread) {
      pathSuffix = '/unread';
      action = 'unread';
    } else if (hasSeq) {
      const seq = Number(kwargs.seq);
      if (!Number.isInteger(seq) || seq <= 0) throw new ArgumentError(`--seq must be a positive integer (got "${kwargs.seq}")`);
      pathSuffix = '/read';
      body = { seq };
      action = `read-to-${seq}`;
    } else {
      pathSuffix = '/read-all';
      action = 'read-all';
    }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use only one mode: either `--unread` or `--seq <n>` (or neither for read-all)
  2. Split the intent into two invocations if both operations are wanted
  3. Fix wrapper scripts to emit the flags conditionally

Example fix

// before
$ slock channel-mark --channel '#ops' --unread --seq 42
Error: --unread and --seq are mutually exclusive
// after
$ slock channel-mark --channel '#ops' --unread
$ slock channel-mark --channel '#ops' --seq 42
Defensive patterns

Strategy: validation

Validate before calling

const flags = [];
if (wantUnread) flags.push('--unread');
else if (seq != null && seq !== '') flags.push('--seq', String(seq));
if (wantUnread && seq != null && seq !== '') throw new Error('choose either --unread or --seq, not both');

Try / catch

try {
  await run(['slock', 'channel-mark', '--channel', channel, ...flags]);
} catch (e) {
  if (e instanceof ArgumentError && /mutually exclusive/.test(e.message)) {
    console.error('Pick one mode: --unread OR --seq <n> OR neither (read-all).');
  } else throw e;
}

Prevention

When it happens

Trigger: Running e.g. `slock channel-mark --channel '#ops' --unread --seq 42` — i.e. `unread` is true and `seq` is a non-empty value (not undefined/null/'').

Common situations: Wrapper scripts that always append --seq while also forwarding --unread from a flag, or users combining examples from docs of different modes.

Related errors


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