Skip to content

Instantly share code, notes, and snippets.

@juanfal
Created December 30, 2012 12:54
Show Gist options
  • Save juanfal/4412682 to your computer and use it in GitHub Desktop.
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
#!/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