20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/xs/apt_cache.rb', line 20
def self.show(pkg, options)
compact = options[:compact]
Open3.popen3("apt-cache show #{pkg}") { |stdin, stdout, stderr|
hash = {}
stdout.each { |line|
if line =~ /([\w\-]+):\s(.+)$/
hash[$1.downcase.to_sym] = $2
end
}
if hash.empty?
puts "FAILED: #{pkg}"
end
if options[:section]
return if not hash[:section] =~ /#{options[:pattern]}/
end
installed = AptCache.installed?(pkg)
if not compact
print " \033[92m*\033[00m #{hash[:section]}/\033[01m#{hash[:package]}\033[00m "
if installed
puts "[\033[01;32mINSTALLED\033[00m]"
else
puts ""
end
puts " \033[32mVersion:\033[00m \033[96m#{hash[:version]}\033[00m"
if hash.has_key? :homepage
puts " \033[32mHomepage:\033[00m #{hash[:homepage]}"
end
puts " \033[32mDescription:\033[00m #{hash[:description]}"
puts " \033[32mDownload size:\033[00m #{((hash[:size].to_i + 1023) / 1024)} KiB"
else
print " \033[92m*\033[00m #{hash[:section]}/\033[01m#{hash[:package]}\033[00m (\033[32m#{hash[:version]}\033[00m): #{hash[:description]} "
if installed
print "[\033[01;32mINSTALLED\033[00m]"
else
print ""
end
end
puts ""
return true
}
false
end
|