-
-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Conversation
The tests are failing on Mountain Lion—are you using any Ruby that's not valid in 1.8? |
That’s entirely possible. I apologize. I’ll install 1.8.7 and see about finding and fixing the issue. (Off the top of my head, I'm guessing that it might be due to my use of |
Aieeee, no. Close, but the actual culprit was my using |
def desc | ||
options = ARGV.options_only | ||
|
||
if options.include?("--decache") |
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.
You can drop the parentheses here.
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.
--decache
feels bit jargon.
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.
It was meant to be either a portmanteau of “delete” and “cache”, or analogous to “decompress”. I’m open to clearer suggestions, though. --delete_cache
?
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’d prefer not to mix underscores and hyphens, so maybe --delete-cache
.
@hivehand Can you show the output of |
descriptions (`-d`) for `<pattern>`. `<pattern>` is by default interpreted | ||
as a literal string; if flanked by slashes, it is instead interpreted as a | ||
regular expression. Formula descriptions are cached, and the cache is | ||
created on the first search, making it slower than succeeding ones. |
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 don’t think “succeeding” is the good word here 😉
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.
How about "subsequent" or "later"?
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.
Yep.
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 agree that “succeeding” is not the good word. I like “subsequent”: I’ll use that.
@hivehand Thanks for doing this! |
require 'descriptions' | ||
require 'cmd/search' | ||
|
||
USAGE =<<EOM |
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.
Since none of internal commands has a usage message. I think we should drop this. Manpage should be sufficiency.
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.
Fair enough. I will make it behave like brew deps
just raise a FormulaUnspecifiedError
instead.
I recommend this be profiled with something like |
The first benchmarks, as requested by @MikeMcQuaid:
More to come as soon as I familiarize myself with I’ll be addressing and/or replying to specific comments shortly. Thank you all for the careful proofreading and detailed feedback! |
|
||
matchers = { | ||
:name => proc { |name, desc| name =~ regex }, | ||
:desc => proc { |name, desc| desc =~ regex }, |
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.
You can use _
for the parameters you’re no using, e.g. { |_, desc| desc =~ regex }
.
I just pushed an update. I believe that this addresses all issues raised and suggestions made, with the exception of @bfontaine’s proposal that I use On the profiling front,
fails with
which stands to reason, since |
@hivehand I wrote a small script to help you profile homebrew. If you install it with |
Maintainers: please hold off merging this: I haven't had the chance to review it yet but would like it before we merge it. |
@cache = {} | ||
CSV.open(CACHE_FILE, 'w') do |csv| | ||
Formula.map do |f| | ||
name, desc = f.name, f.desc |
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.
f.full_name
@hivehand That approach sounds good! |
1. Resurrect the late `brew desc` as a means of geting descriptions for an arbitrary set of formulae via the command line. 2. Create the Descriptions class to do most of the heavy lifting. 3. Update the man page.
Use traditional Hash-construction notation, and deal with the fact that Hash#select in Ruby 1.8.7 and earlier returns an Array of Arrays, instead of a Hash. While we're here: - Make `ruby desc` without arguments print usage, rather than all formulae. - Rename --cache to --recache, and update the manual accordingly. - Sort formulae by name when printing. - Flag formulae with missing descriptions when printing the list.
- Add zsh autocompletion support. - Dispose of the verbose usage message. - Adopt too many tweaks and refinements courtesy of @bfontaine to enumerate. - Replace `--decache` with `--delete-cache` and, for consistency, `--recache` with `--create-cache`. - Update the man page accordingly.
- Use the update report to update only the affected formulae. - Also, refactor the cache-saving code.
- Also refactor using Filepaths
- Refactor update_cache, splitting cache addition and deletion into separate methods. Use those methods to update the cache when tapping or untapping. - Also revise update_cache, and move cache_fresh? while we're at it. - Realign methods' descriptions with reality.
Also remove the Descriptions::delete_cache method, since nothing now uses it.
Apologies in advance if I’m being a pest, but are there any outstanding issues regarding this pull request? The changes have been working well for me, locally, for the past two weeks and change, with minimal impact on performance. I’d still be happy to share |
And, of course, a day after my last comment, I discover the newly-added support for formula renaming in |
The diff looks good to me. If @xu-cheng is happy with it as-is then I'll do some more local testing and merge. |
LGTM |
searches = { | ||
'-s' => :either, | ||
'-n' => :name, | ||
'-d' => :desc |
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.
Would be nice to also have --search
, --name
etc. here.
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.
Added. (In the process, I replaced the somewhat convoluted Hash logic with a case
statement, which should please @bfontaine. 😉)
A couple of final nits but otherwise looks and works great for me 👍 |
Add the '--search', '--name', and '--description' options, and update bash completion accordingly.
Thanks for the great work here @hivehand! Merged! |
Thank you, collectively, for the many excellent suggestions and your patience! |
@hivehand Thanks for getting this into brew. |
@telemachus, you’re welcome. Thanks for hopelessly addicting me to formula descriptions in the first place! |
Such a great example of a feature that we couldn't have implemented well in core as a one-off that the community picked up and got it back into core as a full-fledged, improving feature. 👏 to both of you @telemachus, @hivehand. |
This is an attempt to recreate @telemachus’s
brew desc
tool, using thedesc
component now built into formulae. Like the originalbrew desc
, it lets you look up formulae either by their exact names, or by searching through some combination of name and description.Notes:
desc
to formulae, and uses a cache for performance.brew desc --cache
, or perform a search. This allows people who don’t expect to usebrew desc
to avoid paying ~5 extra seconds with everybrew update
.utils.rb
’s maximum-length-determination logic, with input from @bfontaine, came along for the ride.Caveats:
desc
and the cache work properly with them.ARGV
, so it’s possible that I’m making a lot of unnecessary noise in thedesc.rb
command handling.Open Questions:
brew search --desc
is exactly equivalent tobrew desc -d
. I’m not sure it makes sense to preserve both, particularly since the former was never documented, but for the time being I’ve rewritten it to take advantage of the cache.brew desc
takes several seconds.Feedback is more than welcome.