Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
b265d870
Commit
b265d870
authored
6 years ago
by
Markus Reiter
Browse files
Options
Downloads
Patches
Plain Diff
Allow searching Casks by name.
parent
b21430b1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Library/Homebrew/cmd/search.rb
+9
-8
9 additions, 8 deletions
Library/Homebrew/cmd/search.rb
Library/Homebrew/extend/os/mac/search.rb
+29
-12
29 additions, 12 deletions
Library/Homebrew/extend/os/mac/search.rb
Library/Homebrew/search.rb
+5
-0
5 additions, 0 deletions
Library/Homebrew/search.rb
with
43 additions
and
20 deletions
Library/Homebrew/cmd/search.rb
+
9
−
8
View file @
b265d870
...
...
@@ -52,16 +52,17 @@ module Homebrew
return
end
if
args
.
remaining
.
empty?
if
args
.
remaining
.
empty?
&&
!
args
.
desc?
puts
Formatter
.
columns
(
Formula
.
full_names
.
sort
)
elsif
args
.
desc?
query
=
args
.
remaining
.
join
(
" "
)
string_or_regex
=
query_regexp
(
query
)
Descriptions
.
search
(
string_or_regex
,
:desc
).
print
else
query
=
args
.
remaining
.
join
(
" "
)
string_or_regex
=
query_regexp
(
query
)
return
end
query
=
args
.
remaining
.
join
(
" "
)
string_or_regex
=
query_regexp
(
query
)
if
args
.
desc?
search_descriptions
(
string_or_regex
)
else
remote_results
=
search_taps
(
query
,
silent:
true
)
local_formulae
=
search_formulae
(
string_or_regex
)
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/extend/os/mac/search.rb
+
29
−
12
View file @
b265d870
...
...
@@ -3,24 +3,41 @@ require "hbc/cask_loader"
module
Homebrew
module
Search
def
search_casks
(
string_or_regex
)
if
string_or_regex
.
is_a?
(
String
)
&&
string_or_regex
.
match?
(
HOMEBREW_TAP_CASK_REGEX
)
return
begin
[
Hbc
::
CaskLoader
.
load
(
string_or_regex
).
token
]
rescue
Hbc
::
CaskUnavailableError
[]
module
Extension
def
search_descriptions
(
string_or_regex
)
super
puts
ohai
"Casks"
Hbc
::
Cask
.
to_a
.
extend
(
Searchable
)
.
search
(
string_or_regex
,
&
:name
)
.
each
do
|
cask
|
puts
"
#{
Tty
.
bold
}#{
cask
.
token
}
:
#{
Tty
.
reset
}
#{
cask
.
name
.
join
(
", "
)
}
"
end
end
results
=
Hbc
::
Cask
.
search
(
string_or_regex
,
&
:token
).
sort_by
(
&
:token
)
def
search_casks
(
string_or_regex
)
if
string_or_regex
.
is_a?
(
String
)
&&
string_or_regex
.
match?
(
HOMEBREW_TAP_CASK_REGEX
)
return
begin
[
Hbc
::
CaskLoader
.
load
(
string_or_regex
).
token
]
rescue
Hbc
::
CaskUnavailableError
[]
end
end
results
.
map
do
|
cask
|
if
cask
.
installed?
pretty_installed
(
cask
.
token
)
else
cask
.
token
results
=
Hbc
::
Cask
.
search
(
string_or_regex
,
&
:token
).
sort_by
(
&
:token
)
results
.
map
do
|
cask
|
if
cask
.
installed?
pretty_installed
(
cask
.
token
)
else
cask
.
token
end
end
end
end
prepend
Extension
end
end
This diff is collapsed.
Click to expand it.
Library/Homebrew/search.rb
+
5
−
0
View file @
b265d870
...
...
@@ -12,6 +12,11 @@ module Homebrew
raise
"
#{
query
}
is not a valid regex."
end
def
search_descriptions
(
string_or_regex
)
ohai
"Formulae"
Descriptions
.
search
(
string_or_regex
,
:desc
).
print
end
def
search_taps
(
query
,
silent:
false
)
if
query
.
match?
(
Regexp
.
union
(
HOMEBREW_TAP_FORMULA_REGEX
,
HOMEBREW_TAP_CASK_REGEX
))
_
,
_
,
query
=
query
.
split
(
"/"
,
3
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment