Created
February 24, 2011 14:52
-
-
Save rockpapergoat/842247 to your computer and use it in GitHub Desktop.
accepts an array as arguments on the command line or will loop through /Applications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -wKU | |
# 110224, revised with loop to accept an array | |
def get_version(apps) | |
apps.each do |app| | |
if File.exists?("#{app}/Contents/Info.plist") | |
vers = `/usr/bin/defaults read "#{app}"/Contents/Info CFBundleShortVersionString`.chomp | |
puts "#{app.sub(/\/Applications\//, '')}: #{vers}" | |
$?.success? ? vers : "ERROR: could not get version" | |
else | |
puts "#{app} is not installed." | |
end | |
end | |
end | |
apps = ARGV | |
if ARGV.size == 0 | |
puts "no argument(s) passed, so let's loop through all apps under /Applications.\n\n" | |
apps = Dir.glob("/Applications/*.app") | |
get_version(apps) | |
else | |
get_version(apps) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment