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
68947f2a
Commit
68947f2a
authored
4 years ago
by
EricFromCanada
Browse files
Options
Downloads
Patches
Plain Diff
cmd/options: add flag to list a command's options
parent
b4cd99c6
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/options.rb
+34
-1
34 additions, 1 deletion
Library/Homebrew/cmd/options.rb
docs/Manpage.md
+2
-0
2 additions, 0 deletions
docs/Manpage.md
manpages/brew.1
+4
-0
4 additions, 0 deletions
manpages/brew.1
with
40 additions
and
1 deletion
Library/Homebrew/cmd/options.rb
+
34
−
1
View file @
68947f2a
...
...
@@ -3,6 +3,7 @@
require
"formula"
require
"options"
require
"cli/parser"
require
"commands"
module
Homebrew
module_function
...
...
@@ -20,8 +21,10 @@ module Homebrew
description:
"Show options for formulae that are currently installed."
switch
"--all"
,
description:
"Show options for all available formulae."
flag
"--command="
,
description:
"Show options for the specified <command>."
switch
:debug
conflicts
"--installed"
,
"--all"
conflicts
"--installed"
,
"--all"
,
"--command"
end
end
...
...
@@ -32,6 +35,22 @@ module Homebrew
puts_options
Formula
.
to_a
.
sort
elsif
args
.
installed?
puts_options
Formula
.
installed
.
sort
elsif
!
args
.
command
.
nil?
path
=
Commands
.
path
(
args
.
command
)
odie
"Unknown command:
#{
args
.
command
}
"
unless
path
cmd_options
=
if
cmd_parser
=
CLI
::
Parser
.
from_cmd_path
(
path
)
cmd_parser
.
processed_options
.
map
do
|
short
,
long
,
_
,
desc
|
[
long
||
short
,
desc
]
end
else
cmd_comment_options
(
path
)
end
if
args
.
compact?
puts
cmd_options
.
sort
.
map
(
&
:first
)
*
" "
else
cmd_options
.
sort
.
each
{
|
option
,
desc
|
puts
"
#{
option
}
\n\t
#{
desc
}
"
}
puts
end
elsif
args
.
no_named?
raise
FormulaUnspecifiedError
else
...
...
@@ -39,6 +58,20 @@ module Homebrew
end
end
def
cmd_comment_options
(
cmd_path
)
options
=
[]
comment_lines
=
cmd_path
.
read
.
lines
.
grep
(
/^#:/
)
return
options
if
comment_lines
.
empty?
# skip the comment's initial usage summary lines
comment_lines
.
slice
(
2
..-
1
).
each
do
|
line
|
if
/ (?<option>-[-\w]+) +(?<desc>.*)$/
=~
line
options
<<
[
option
,
desc
]
end
end
options
end
def
puts_options
(
formulae
)
formulae
.
each
do
|
f
|
next
if
f
.
options
.
empty?
...
...
This diff is collapsed.
Click to expand it.
docs/Manpage.md
+
2
−
0
View file @
68947f2a
...
...
@@ -340,6 +340,8 @@ Show install options specific to *`formula`*.
Show options for formulae that are currently installed.
*
`--all`
:
Show options for all available formulae.
*
`--command`
:
Show options for the specified
*`command`*
.
### `outdated` [*`options`*] [*`formula`*]
...
...
This diff is collapsed.
Click to expand it.
manpages/brew.1
+
4
−
0
View file @
68947f2a
...
...
@@ -456,6 +456,10 @@ Show options for formulae that are currently installed\.
\fB\-\-all\fR
Show options for all available formulae\.
.
.TP
\fB\-\-command\fR
Show options for the specified \fIcommand\fR\.
.
.SS "\fBoutdated\fR [\fIoptions\fR] [\fIformula\fR]"
List installed formulae that have an updated version available\. By default, version information is displayed in interactive shells, and suppressed otherwise\.
.
...
...
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