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
cmd/prof: improve error messages #14652
cmd/prof: improve error messages #14652
Conversation
Review period will end on 2023-02-17 at 02:28:36 UTC. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! One suggestion (that probably violates brew style
so may want to do manually).
Library/Homebrew/dev-cmd/prof.rb
Outdated
when ".rb" | ||
# expected file extension so we do nothing | ||
when ".sh" | ||
raise UsageError, "`#{cmd}` is a Bash command!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise UsageError, "`#{cmd}` is a Bash command!" | |
raise UsageError, "As `#{cmd}` is a Bash command it cannot be profiled with `brew prof`! Try `hyperfine` for benchmarking instead." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/u/l/Homebrew (improve-prof-errors|✚1) [1]$ brew prof --version
Usage: brew prof [--stackprof] command [...]
Run Homebrew with a Ruby profiler. For example, brew prof readall.
--stackprof Use stackprof instead of ruby-prof (the
default).
-d, --debug Display any debugging information.
-q, --quiet Make some output more quiet.
-v, --verbose Make some output more verbose.
-h, --help Show this message.
Error: Invalid usage: `--version` is a Bash command!
Try `hyperfine` for benchmarking instead.
Wary of the 80 character limit I opted for this instead.
- Provide an error message when the command is unknown. - Suggest running the command again with `--` if there is an invalid option which might have been meant for a subcommand.
3b62527
to
d216b33
Compare
Review period ended. |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?Small changes to provide better errors when using
brew prof
.--
if there is an invalid option which might have been meant for a subcommand.Before
After