blob: b9bbb12ecefc59c4f667a22efec0d2e08a4ce7aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
|