commands: support list all commands without header
This commit is contained in:
parent
609af678fd
commit
a2d9d68591
@ -1,24 +1,33 @@
|
|||||||
module Homebrew
|
module Homebrew
|
||||||
def commands
|
def commands
|
||||||
# Find commands in Homebrew/cmd
|
if ARGV.include? "--quiet"
|
||||||
with_directory = false
|
cmds = internal_commands + external_commands
|
||||||
cmds = (HOMEBREW_REPOSITORY/"Library/Homebrew/cmd").
|
cmds += HOMEBREW_INTERNAL_COMMAND_ALIASES.keys if ARGV.include? "--include-aliases"
|
||||||
children(with_directory).
|
puts_columns cmds.sort
|
||||||
map {|f| File.basename(f, '.rb')}
|
else
|
||||||
puts "Built-in commands"
|
# Find commands in Homebrew/cmd
|
||||||
puts_columns cmds
|
puts "Built-in commands"
|
||||||
|
puts_columns internal_commands
|
||||||
|
|
||||||
# Find commands in the path
|
# Find commands in the path
|
||||||
exts = paths.map{ |p| Dir["#{p}/*"] }.flatten.
|
unless (exts = external_commands).empty?
|
||||||
map{ |f| File.basename f }.
|
puts
|
||||||
select{ |f| f =~ /^brew-(.+)/ }.
|
puts "External commands"
|
||||||
map{ |f| File.basename(f, '.rb')[5..-1] }.
|
puts_columns exts
|
||||||
reject{ |f| f =~ /\./ }
|
end
|
||||||
|
|
||||||
unless exts.empty?
|
|
||||||
puts
|
|
||||||
puts "External commands"
|
|
||||||
puts_columns exts
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def internal_commands
|
||||||
|
with_directory = false
|
||||||
|
(HOMEBREW_REPOSITORY/"Library/Homebrew/cmd").
|
||||||
|
children(with_directory).
|
||||||
|
map {|f| File.basename(f, '.rb')}
|
||||||
|
end
|
||||||
|
|
||||||
|
def external_commands
|
||||||
|
paths.map{ |p| Dir["#{p}/brew-*"] }.flatten.
|
||||||
|
map{ |f| File.basename(f, '.rb')[5..-1] }.
|
||||||
|
reject{ |f| f =~ /\./ }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -75,9 +75,12 @@ Note that these flags should only appear after a command.
|
|||||||
* `command` <cmd>:
|
* `command` <cmd>:
|
||||||
Display the path to the file which is used when invoking `brew <cmd>`.
|
Display the path to the file which is used when invoking `brew <cmd>`.
|
||||||
|
|
||||||
* `commands`:
|
* `commands [--quiet [--include-aliases]]`:
|
||||||
Show a list of built-in and external commands.
|
Show a list of built-in and external commands.
|
||||||
|
|
||||||
|
If `--quiet` is passed, list only the names of commands without the header.
|
||||||
|
With `--include-aliases`, the aliases of internal commands will be included.
|
||||||
|
|
||||||
* `config`:
|
* `config`:
|
||||||
Show Homebrew and system configuration useful for debugging. If you file
|
Show Homebrew and system configuration useful for debugging. If you file
|
||||||
a bug report, you will likely be asked for this information if you do not
|
a bug report, you will likely be asked for this information if you do not
|
||||||
|
@ -80,7 +80,10 @@ If \fB\-s\fR is passed, scrubs the cache, removing downloads for even the latest
|
|||||||
\fBcommand\fR \fIcmd\fR: Display the path to the file which is used when invoking \fBbrew <cmd>\fR\.
|
\fBcommand\fR \fIcmd\fR: Display the path to the file which is used when invoking \fBbrew <cmd>\fR\.
|
||||||
.
|
.
|
||||||
.IP "\(bu" 4
|
.IP "\(bu" 4
|
||||||
\fBcommands\fR: Show a list of built\-in and external commands\.
|
\fBcommands [\-\-quiet [\-\-include\-aliases]]\fR: Show a list of built\-in and external commands\.
|
||||||
|
.
|
||||||
|
.IP
|
||||||
|
If \fB\-\-quiet\fR is passed, list only the names of commands without the header\. With \fB\-\-include\-aliases\fR, the aliases of internal commands will be included\.
|
||||||
.
|
.
|
||||||
.IP "\(bu" 4
|
.IP "\(bu" 4
|
||||||
\fBconfig\fR: Show Homebrew and system configuration useful for debugging\. If you file a bug report, you will likely be asked for this information if you do not provide it\.
|
\fBconfig\fR: Show Homebrew and system configuration useful for debugging\. If you file a bug report, you will likely be asked for this information if you do not provide it\.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user