jdx/mise · error

--name-only cannot be used with --json, --extended, or…

Error message

--name-only cannot be used with --json, --extended, or --usage

What it means

When merging the `mise tasks ls` options provided before a subcommand with the subcommand's own options, merge() enforces mutual exclusivity: `--name-only` prints bare task names and cannot be combined with output modes that add structure or metadata (`--json`, `--extended`, `--usage`).

Solutions

  1. Remove `--name-only` when you need --json, --extended, or --usage output (structured modes already name tasks)
  2. Drop the structured flag if you only want a plain list of names, keeping --name-only alone
  3. Fix the alias/wrapper that pre-sets --name-only so it doesn't collide with flags you pass explicitly

Example fix

// before
mise tasks ls --name-only --json
// error: --name-only cannot be used with --json, --extended, or --usage
// after
mise tasks ls --json          # or: mise tasks ls --name-only
Defensive patterns

Strategy: validation

Validate before calling

# shellcheck disable=SC2086
[[ " $flags " != *" --name-only "* ]] || ! [[ " $flags " =~ --(json|extended|usage) ]] && mise tasks ls $flags

Prevention

When it happens

Trigger: Invoking `mise tasks ls --name-only ... --json` (or --extended / --usage), including cases where the flags come from different positions that get merged in `Commands::Ls(ls.merge(cmd))` — the combined state has name_only set alongside one of the structured-output flags.

Common situations: Shell aliases that already inject --name-only while the user adds --json; scripts concatenating flag sets; users assuming --name-only merely filters --json output.

Understand the failure class

Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/ad3a5d59c1ea1a64. Report an issue: GitHub.

Appendix: source

Thrown at src/cli/tasks/ls.rs:111

impl TasksLs {
    pub(super) fn merge(mut self, later: Self) -> Result<Self> {
        if later.global || later.local {
            self.global = later.global;
            self.local = later.local;
        }
        self.json |= later.json;
        self.extended |= later.extended;
        self.all |= later.all;
        self.complete |= later.complete;
        self.hidden |= later.hidden;
        self.name_only |= later.name_only;
        self.no_header |= later.no_header;
        self.sort = later.sort.or(self.sort);
        self.sort_order = later.sort_order.or(self.sort_order);
        self.usage |= later.usage;
        if self.name_only && (self.json || self.extended || self.usage) {
            bail!("--name-only cannot be used with --json, --extended, or --usage");
        }
        Ok(self)
    }

    pub(super) fn has_options(&self) -> bool {
        self.json || self.has_non_json_options()
    }

    pub(super) fn has_non_json_options(&self) -> bool {
        self.global
            || self.local
            || self.extended
            || self.all
            || self.complete
            || self.hidden
            || self.name_only
            || self.no_header
            || self.sort.is_some()

View on GitHub (pinned to 533346cc37)