aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXu Cheng2015-07-09 19:50:53 +0800
committerXu Cheng2015-07-11 00:07:29 +0800
commita2d9d68591bf78ed8267d7e273c16b9043a6be1b (patch)
treea013fa243261b7d752015e3c8aafe11fdfa2e39c
parent609af678fdb12d270f185e12aa49804e245aff70 (diff)
downloadbrew-a2d9d68591bf78ed8267d7e273c16b9043a6be1b.tar.bz2
commands: support list all commands without header
-rw-r--r--Library/Homebrew/cmd/commands.rb45
-rw-r--r--Library/Homebrew/manpages/brew.1.md5
-rw-r--r--share/man/man1/brew.15
3 files changed, 35 insertions, 20 deletions
diff --git a/Library/Homebrew/cmd/commands.rb b/Library/Homebrew/cmd/commands.rb
index aefc7e30e..a41099982 100644
--- a/Library/Homebrew/cmd/commands.rb
+++ b/Library/Homebrew/cmd/commands.rb
@@ -1,24 +1,33 @@
module Homebrew
def commands
- # Find commands in Homebrew/cmd
- with_directory = false
- cmds = (HOMEBREW_REPOSITORY/"Library/Homebrew/cmd").
- children(with_directory).
- map {|f| File.basename(f, '.rb')}
- puts "Built-in commands"
- puts_columns cmds
-
- # Find commands in the path
- exts = paths.map{ |p| Dir["#{p}/*"] }.flatten.
- map{ |f| File.basename f }.
- select{ |f| f =~ /^brew-(.+)/ }.
- map{ |f| File.basename(f, '.rb')[5..-1] }.
- reject{ |f| f =~ /\./ }
+ if ARGV.include? "--quiet"
+ cmds = internal_commands + external_commands
+ cmds += HOMEBREW_INTERNAL_COMMAND_ALIASES.keys if ARGV.include? "--include-aliases"
+ puts_columns cmds.sort
+ else
+ # Find commands in Homebrew/cmd
+ puts "Built-in commands"
+ puts_columns internal_commands
- unless exts.empty?
- puts
- puts "External commands"
- puts_columns exts
+ # Find commands in the path
+ unless (exts = external_commands).empty?
+ puts
+ puts "External commands"
+ puts_columns exts
+ 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
diff --git a/Library/Homebrew/manpages/brew.1.md b/Library/Homebrew/manpages/brew.1.md
index ede0d0224..e371c470e 100644
--- a/Library/Homebrew/manpages/brew.1.md
+++ b/Library/Homebrew/manpages/brew.1.md
@@ -75,9 +75,12 @@ Note that these flags should only appear after a command.
* `command` <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.
+ 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`:
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
diff --git a/share/man/man1/brew.1 b/share/man/man1/brew.1
index f3f80c76d..026195507 100644
--- a/share/man/man1/brew.1
+++ b/share/man/man1/brew.1
@@ -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\.
.
.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
\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\.