Sha256: 04216535eefd1fd0cf99cfa259f1953d7981987d5e0cee640ec23c7908c0bbf4
Contents?: true
Size: 998 Bytes
Versions: 24
Compression:
Stored size: 998 Bytes
Contents
#!/usr/bin/env ruby $-w = true $:.unshift File.dirname($0) + '/../lib' require 'osx-wrappers' require 'getoptlong' require 'vpim/vcard' require 'osx-wrappers' HELP =<<EOF Usage: ab-query.rb [--me] [--all] Queries the OS X Address Book for vCards. -h, --help print this helpful message -m, --me list my vCard -a, --all list all vCards EOF opts = GetoptLong.new( [ "--help", "-h", GetoptLong::NO_ARGUMENT ], [ "--me", "-m", GetoptLong::NO_ARGUMENT ], [ "--all", "-a", GetoptLong::NO_ARGUMENT ] ) abook = nil opts.each do |opt, arg| case opt when "--help" then puts HELP exit 0 when "--all" then abook = OSX::ABAddressBook.sharedAddressBook unless abook abook.people.to_a.each { |person| puts person.vCard } when "--me" then abook = OSX::ABAddressBook.sharedAddressBook unless abook puts abook.me.vCard end end unless abook puts HELP exit 1 end
Version data entries
24 entries across 24 versions & 11 rubygems