Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to not display Usage in case of errors not related to parameters #745

Open
dvilker opened this issue Jan 26, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@dvilker
Copy link

dvilker commented Jan 26, 2025

Is your feature request related to a problem? Please describe.
For example, now, when I run changie batch auto, if there are no changes, I get:

Error: no unreleased changes found for automatic bumping
Usage:
  changie batch version|major|minor|patch|auto [flags]

Flags:
  -d, --dry-run              Print batched changes instead of writing to disk, does not delete fragments
      --footer-path string   Path to version footer file in unreleased directory
  -f, --force                Force a new version file even if one already exists
      --header-path string   Path to version header file in unreleased directory
  -h, --help                 help for batch
  -i, --include strings      Include extra directories to search for change files, relative to change directory
  -k, --keep                 Keep change fragments instead of deleting them
  -m, --metadata strings     Metadata values to append to version
      --move-dir string      Path to move unreleased changes
  -p, --prerelease strings   Prerelease values to append to version
  -j, --project string       Specify which project version we are batching
      --remove-prereleases   Remove existing prerelease versions

no unreleased changes found for automatic bumping

What's confusing is that it seems like the parameters are set incorrectly, not that there is a state error.

Describe the solution you'd like
Either remove Usage altogether in this case, or remove it if some parameter is present (--do-not-show-usage).

Describe alternatives you've considered
&2>/dev/null, but this looks strange, because another text error should also be sent to stderr (in stdout now).

@dvilker dvilker added the enhancement New feature or request label Jan 26, 2025
@miniscruff
Copy link
Owner

Looks like
https://github.com/spf13/cobra/blob/09d5664f34e3f7571560e48ccb74c8904b671e87/command.go#L234-L235
is what we should enable for this. I think its fair as I always do find this strange.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants