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

Version Path
vpim-24.2.20 samples/ab-query.rb
fraser-vpim-0.658 samples/ab-query.rb
fraser-vpim-0.659 samples/ab-query.rb
fraser-vpim-rails-0.658 samples/ab-query.rb
fraser-vpim-rails-0.659 samples/ab-query.rb
xing-vpim-0.658.1 samples/ab-query.rb
vpim-13.11.11 samples/ab-query.rb
vpim2-0.0.1 samples/ab-query.rb
vpim-rails-reinteractive-0.7 samples/ab-query.rb
vpim-rails-0.665 samples/ab-query.rb
thoughtafter-vpim-0.7.0.1 samples/ab-query.rb
vpim-rails-0.664 samples/ab-query.rb
vpim-rails-0.663 samples/ab-query.rb
vpim-rails-0.662 samples/ab-query.rb
scashin133-vpim-9.4.0 samples/ab-query.rb
vpim-rails-0.661 samples/ab-query.rb
mumboe-vpim-0.7 samples/ab-query.rb
mumboe-vpim-0.695 samples/ab-query.rb
fairtilizer-vpim-0.695 samples/ab-query.rb
vpim-0.619 samples/ab-query.rb