From a2d9d68591bf78ed8267d7e273c16b9043a6be1b Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Thu, 9 Jul 2015 19:50:53 +0800 Subject: commands: support list all commands without header --- Library/Homebrew/cmd/commands.rb | 45 ++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 18 deletions(-) (limited to 'Library/Homebrew/cmd/commands.rb') 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 -- cgit v1.2.3