Skip to content

fix(ux): show helpful error messages on missing positional args - #65

Merged
natikgadzhi merged 1 commit into
mainfrom
improve-help-messages
Jun 5, 2026
Merged

natikgadzhi merged 1 commit into
mainfrom
improve-help-messages

Conversation

@natikgadzhi

Copy link
Copy Markdown
Owner

Summary

  • Adds exactlyOneArg() helper that replaces cobra.ExactArgs(1) across 8 commands, producing a human-readable error with usage and examples when the user forgets the required positional arg
  • Changes bare users (no subcommand) to show help/subcommand list instead of silently running users list
  • Keeps rootCmd.SilenceUsage = true so runtime errors (auth failures, API errors) still don't dump usage

Before

$ slack-cli channels get
Error: accepts 1 arg(s), received 0

After

$ slack-cli channels get
slack-cli channels get requires a channel name or ID

Usage:
  slack-cli channels get <name|id> [flags]

Examples:
  slack-cli channels get general --since 2d
  slack-cli channels get C12345678

Commands updated

channels get, channels search, channels members, users get, users search, files read, emojis search, canvases read

Test plan

  • go build ./... clean
  • go vet ./... clean
  • go test ./... all pass (including new TestExactlyOneArg_* tests)
  • Manually verified each command prints the correct message with 0 args
  • Manually verified "too many args" case (channels get foo bar) prints concise error
  • Verified bare users shows help with subcommand list

🤖 Generated with Claude Code

Replace cobra.ExactArgs(1) with a custom exactlyOneArg() validator that
shows the command's required argument, usage line, and examples when the
user forgets the positional arg. This keeps SilenceUsage=true globally
(no usage dump on runtime errors) while giving clear guidance on arg
validation failures.

Commands updated: channels get, channels search, channels members,
users get, users search, files read, emojis search, canvases read.

Also changes bare `users` (no subcommand) to show help instead of
silently running `users list`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@natikgadzhi
natikgadzhi merged commit 1292864 into main Jun 5, 2026
1 check failed
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.

1 participant