diff options
| author | Adam Vandenberg | 2013-09-14 16:58:26 -0700 |
|---|---|---|
| committer | Adam Vandenberg | 2013-09-17 06:44:25 -0700 |
| commit | 5b77eaf15f1276bbafdea8081acd6e4905ca30d1 (patch) | |
| tree | 74eca6c739f58ce1d5660f9d29f7ef184b7bc64a /Library/Homebrew/cmd/commands.rb | |
| parent | 4c2cee38dfe682c7375facc5bcf0e28c467e47df (diff) | |
| download | homebrew-5b77eaf15f1276bbafdea8081acd6e4905ca30d1.tar.bz2 | |
brew commands
Shows a list of built-in commands (but not shortcuts) and searches
for any external commands on the path.
Closes #22509.
Diffstat (limited to 'Library/Homebrew/cmd/commands.rb')
| -rw-r--r-- | Library/Homebrew/cmd/commands.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Library/Homebrew/cmd/commands.rb b/Library/Homebrew/cmd/commands.rb new file mode 100644 index 000000000..b9bbb12ec --- /dev/null +++ b/Library/Homebrew/cmd/commands.rb @@ -0,0 +1,33 @@ +module Homebrew extend self + def paths + @paths ||= ENV['PATH'].split(File::PATH_SEPARATOR).collect do |p| + begin + File.expand_path(p).chomp('/') + rescue ArgumentError + onoe "The following PATH component is invalid: #{p}" + end + end.uniq.compact + end + + def commands + # Find commands in Homebrew/cmd + cmds = (HOMEBREW_REPOSITORY/"Library/Homebrew/cmd"). + children(with_directory=false). + 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 =~ /\./ } + + unless exts.empty? + puts + puts "External commands" + puts_columns exts + end + end +end |
