#!/usr/bin/ruby $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'arson' require 'arson/colorful' if ARGV.to_s == "" puts "arson #{Arson::VERSION.join('.')} [Colin 'Evaryont' Shea ]" puts "Please specifiy what to search for as the parameters to this script:" puts Arson.colorful(:italic, " #{Arson::PROGRAM} pacman") puts "" puts "If you want to download a package, run #{Arson::PROGRAM} as such:" puts Arson.colorful(:italic, " #{Arson::PROGRAM} aur/arson") puts "(note: you can include the -category bit if you wish)" puts "" puts "Passing '?' to arson will cause it to check for any upgrades" exit 1 end # Old regexp /^aur(?:-.*)\/(.*)$/ if pkg = ARGV.to_s.scan(/aur(-.*?)?\/(.*)/i).flatten[1] if pkg = Arson.find_exact(pkg) puts "Downloading #{pkg['Name']}..." Arson.download(pkg) exit 0 else warn "I think you attempted to download a package, but I couldn't find it" exit 0 end end if ARGV.to_s =~ /\?/ print "Checking for upgrades..." $stdout.flush upgrades = Arson.check_upgrades unless upgrades.empty? print "\n" $stdout.flush upgrades.each do |line, new_version| puts "#{line.strip} #{Arson::ASCII_CHECK} #{Arson.colorful("Green", new_version)}" end else puts "Nothing to update" end exit 0 end packages = Arson.search(ARGV) if packages.length > 1 packages.each do |pkg| name = Arson.colorful("White", pkg['Name']) name = Arson.colorful("Red", name) if pkg["OutOfDate"] == "1" if Arson::Categories[pkg['CategoryID'].to_i] && Arson::Categories[pkg['CategoryID'].to_i] != "nil" category = "-#{Arson::Categories[pkg['CategoryID'].to_i]}" else category = "" end puts <<-HERE #{Arson.colorful("Magenta", "aur#{category}")}/#{name} #{Arson.colorful("Green",pkg['Version'])} #{pkg['Description']} HERE $stdout.flush end elsif packages.length == 1 puts "Downloading #{packages.first['Name']}..." Arson.download(packages.first) exit 0 end if File.exists? "/usr/bin/pacman-color" exec "/usr/bin/pacman-color -Ss #{ARGV.join(' ')}" else exec "/usr/bin/pacman -Ss #{ARGV.join(' ')}" end