Skip to content

fix(cli): name the missing argument in usage errors (#32) - #34

Merged
steveclarke merged 1 commit into
masterfrom
32-ls-scenes-usage
Jul 25, 2026
Merged

steveclarke merged 1 commit into
masterfrom
32-ls-scenes-usage

Conversation

@steveclarke

@steveclarke steveclarke commented Jul 25, 2026 •

Copy link
Copy Markdown
Owner

Closes #32.

ucmix ls scenes failed with ✗ accepts 1 arg(s), received 0 — cobra's bare count message, which never says what the argument is. Since ls projects takes none, it read as though ls scenes should list everything.

Now:

$ ucmix ls scenes
✗ ls scenes needs a project name
run `ucmix ls projects` to see them — quote names that contain spaces

The quoting note earns its place: real project names look like 03.135 Main Live.proj, so the common failure is a forgotten quote, not an omitted argument. Unquoted, cobra sees three args and the same message fires — the hint has to cover both.

How

requireArgs (internal/cli/args.go) wraps a cobra.PositionalArgs validator and turns a wrong count into an errs.CLIError naming what the command wants, plus a hint pointing at how to find the value. When there's nothing better to say the hint falls back to the command's usage line:

$ ucmix verify
✗ verify needs a config file
usage: ucmix verify <config.yml>

Applied to every command that validates positional args: ls scenes, recall, store, rename, delete, channel, mix, send, get, fade, apply, verify, dump, and the profile subcommands. set uses ArbitraryArgs and never errors, so it's untouched.

Not done deliberately

  • No cross-project ls scenes. The issue left that open; this stays a usage-message fix.
  • No behavior changes beyond the error text. Same validators, same exit codes.

Known limitation, pre-existing

--no-color is not honored on the arg-validation path: ui.Init runs in PersistentPreRun, which cobra skips when Args validation fails, so ucmix --no-color ls scenes still emits ANSI. NO_COLOR=1 does work (the package-level initializer reads it). This predates the change — cobra's bare message was styled too — but this PR adds a second styled line there, so it's worth naming. Fixing it means restructuring Execute(), out of scope here.

Testing

  • just test — 378 unit (was 373); table-driven TestRequireArgs covers valid counts, too few, too many, and the usage-line fallback (including that cobra's [flags] suffix is trimmed).
  • just test-e2e — 75 BATS (was 72); new cases in test/errors.bats for ls scenes with no project, get/recall missing args, and the usage-line fallback.
  • just lint, just vet clean.
  • Against the real 32R (profile studiolive32r), read-only — nothing was written: ls projects, ls scenes "03.135 Main Live.proj", get line/ch1/mute, dump line/ch1, and --json output all still work. Also confirmed the arg errors for store, rename, delete, apply, and fade fire with the live profile current and exit non-zero without contacting the board, and that the unquoted ls scenes 03.135 Main Live.proj case produces the message above.
  • The write commands themselves weren't exercised on hardware: this change only affects argument-count validation, which fails before any connection is opened, so writing to a live show-state board shared with other sessions would have modified real state for no added signal.

https://claude.ai/code/session_01Ggvmi2jXGiS5ffLr7Hfn6d

`ucmix ls scenes` failed with cobra's bare "accepts 1 arg(s), received 0",
which never says what the argument is. Since `ls projects` takes none, it
read as though `ls scenes` should list everything.

requireArgs wraps a cobra positional-arg validator and turns a wrong count
into an errs.CLIError that names what the command wants, with a hint
pointing at how to find the value (falling back to the command's usage
line). Applied to every command that validates positional args.

Claude-Session: https://claude.ai/code/session_01Ggvmi2jXGiS5ffLr7Hfn6d
@steveclarke
steveclarke merged commit d54821c into master Jul 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ls scenes: unhelpful error when the project argument is missing

1 participant