Skip to content

do not display suggestions if command fails#122

Merged
gtrrz-victor merged 2 commits intomainfrom
gtrrz-victor/do-not-show-suggestions-if-cmd-fails
Jan 29, 2026
Merged

do not display suggestions if command fails#122
gtrrz-victor merged 2 commits intomainfrom
gtrrz-victor/do-not-show-suggestions-if-cmd-fails

Conversation

@gtrrz-victor
Copy link
Contributor

@gtrrz-victor gtrrz-victor commented Jan 29, 2026

Only display suggestions when the command fails due to bad CLI usage (wrong command, wrong flags, etc.). That's where they're useful. For other failures, it's just noise.

Current:

$entire rewind --to xxx
Usage:
  entire rewind [flags]

Flags:
  -h, --help        help for rewind
      --list        List available rewind points (JSON output)
      --logs-only   Only restore logs, don't modify working directory (for logs-only points)
      --reset       Reset branch to commit (destructive, for logs-only points)
      --to string   Rewind to specific commit ID (non-interactive)

rewind point not found: xxx

How it looks now:

$entire rewindd --tooo
Usage:
  entire
  entire [command]

Available Commands:
  clean            Clean up orphaned entire's data
  disable          Disable Entire
  enable           Enable Entire
  explain          Explain a session or commit
  help             Help about any command
  resume           Switch to a branch and resume its session
  rewind           Rewind commands for session management
  status           Show Entire status
  version          Show version information

Use "entire [command] --help" for more information about a command.

Error: Invalid usage: unknown command "rewindd" for "entire"

Did you mean this?
        rewind
-----------------------------
$entire rewind --tooo
Usage:
  entire
  entire [command]

Available Commands:
  clean            Clean up orphaned entire's data
  disable          Disable Entire
  enable           Enable Entire
  explain          Explain a session or commit
  help             Help about any command
  resume           Switch to a branch and resume its session
  rewind           Rewind commands for session management
  status           Show Entire status
  version          Show version information

Use "entire [command] --help" for more information about a command.

Error: Invalid usage: unknown flag: --tooo
-----------------------------
$entire rewind --to xxx
rewind point not found: xxx

Note

Low Risk
Low risk CLI UX change that adjusts when usage output is printed; main concern is the string-based detection of "unknown" errors potentially missing/overmatching in future Cobra error messages.

Overview
Reduces noisy CLI output by silencing Cobra usage by default (SilenceUsage: true) and moving usage/error printing into main.go.

main.go now only prints the full usage + "Invalid usage" error message for bad CLI usage cases (unknown command/unknown flag); other runtime errors are printed plainly, and SilentError continues to suppress duplicate output.

Written by Cursor Bugbot for commit 41aa312. This will update automatically on new commits. Configure here.

Entire-Checkpoint: 7ed4051c8a85
@gtrrz-victor gtrrz-victor requested a review from a team as a code owner January 29, 2026 02:13
Copilot AI review requested due to automatic review settings January 29, 2026 02:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request improves the CLI's error handling by only displaying usage suggestions when command failures are due to bad CLI usage (unknown commands or invalid flags), rather than showing them for all errors. This reduces noise for operational failures.

Changes:

  • Added selective error handling in main.go to distinguish between CLI usage errors (unknown commands) and operational errors
  • Set SilenceUsage: true in root command to prevent automatic usage display
  • Added custom flag error handler that displays usage and wraps errors with SilentError

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
cmd/entire/main.go Added error type detection to show suggestions only for unknown commands, implemented showSuggestion function for custom error messages with command suggestions
cmd/entire/cli/root.go Enabled SilenceUsage and added SetFlagErrorFunc to handle flag errors with custom formatting

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@gtrrz-victor gtrrz-victor merged commit 4d64950 into main Jan 29, 2026
4 checks passed
@gtrrz-victor gtrrz-victor deleted the gtrrz-victor/do-not-show-suggestions-if-cmd-fails branch January 29, 2026 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants