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
d068d87b
Commit
d068d87b
authored
5 years ago
by
EricFromCanada
Browse files
Options
Downloads
Patches
Plain Diff
desc: fix search options
parent
30c4383e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Library/Homebrew/cmd/desc.rb
+16
-15
16 additions, 15 deletions
Library/Homebrew/cmd/desc.rb
with
16 additions
and
15 deletions
Library/Homebrew/cmd/desc.rb
+
16
−
15
View file @
d068d87b
...
...
@@ -19,41 +19,42 @@ module Homebrew
Formula descriptions are cached; the cache is created on the
first search, making that search slower than subsequent ones.
EOS
flag
"-s"
,
"--search
=
"
,
switch
"-s"
,
"--search"
,
description:
"Search both names and descriptions for <text>. If <text> is flanked by "
\
"slashes, it is interpreted as a regular expression."
flag
"-n"
,
"--name
=
"
,
switch
"-n"
,
"--name"
,
description:
"Search just names for <text>. If <text> is flanked by slashes, it is "
\
"interpreted as a regular expression."
flag
"-d"
,
"--description
=
"
,
switch
"-d"
,
"--description"
,
description:
"Search just descriptions for <text>. If <text> is flanked by slashes, "
\
"it is interpreted as a regular expression."
switch
:verbose
conflicts
"--search="
,
"--name="
,
"--description="
conflicts
"--search"
,
"--name"
,
"--description"
min_named
1
end
end
def
desc
desc_args
.
parse
search_type
=
[]
search_type
<<
:either
if
args
.
search
search_type
<<
:name
if
args
.
name
search_type
<<
:desc
if
args
.
description
odie
"You must provide a search term."
if
search_type
.
present?
&&
args
.
no_named?
results
=
if
search_type
.
empty?
raise
FormulaUnspecifiedError
if
args
.
no_named?
search_type
=
if
args
.
search?
:either
elsif
args
.
name?
:name
elsif
args
.
description?
:desc
end
results
=
if
search_type
.
nil?
desc
=
{}
args
.
formulae
.
each
{
|
f
|
desc
[
f
.
full_name
]
=
f
.
desc
}
Descriptions
.
new
(
desc
)
else
arg
=
args
.
named
.
join
(
" "
)
string_or_regex
=
query_regexp
(
arg
)
query
=
args
.
named
.
join
(
" "
)
string_or_regex
=
query_regexp
(
query
)
CacheStoreDatabase
.
use
(
:descriptions
)
do
|
db
|
cache_store
=
DescriptionCacheStore
.
new
(
db
)
Descriptions
.
search
(
string_or_regex
,
search_type
.
first
,
cache_store
)
Descriptions
.
search
(
string_or_regex
,
search_type
,
cache_store
)
end
end
...
...
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