Created
December 30, 2012 12:54
-
-
Save juanfal/4412682 to your computer and use it in GitHub Desktop.
Display fields of a given plist file, if second parameter filter (like regexp) by it
This file contains hidden or 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 | |
# plistread.rb | |
require 'plist' | |
if ARGV.length == 0 | |
puts "Use: plistread.rb file.plist [attribute]" | |
exit 0 | |
end | |
filter = case ARGV.length | |
when 1 then /.*/ | |
when 2 then /#{ARGV[1]}/ | |
end | |
Plist::parse_xml(ARGV[0]).sort.each {|k, v| | |
puts("%40s: %s" % [k, v.to_s]) if k =~ filter | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment