#!/usr/bin/env python

# The fixed pygooglevoice Python binding are required to use this script:
#
#   cd software
#   git clone git@github.com:pettazz/pygooglevoice.git
#   cd pygooglevoice
#   python setup.py install

from googlevoice import Voice
from googlevoice.util import input

import re
from optparse import OptionParser


def main():
  parser = OptionParser()
  parser.add_option("-n", dest="phoneNumber",
                    help="phone number")
  parser.add_option("-m", dest="message",
                    help="text of message")
  parser.add_option("-p", dest="password", default="",
                    help="Google Voice password")
  parser.add_option("-v", action="store_true", dest="verbose", default=False,
                    help="verbose mode")
  (options, args) = parser.parse_args()

  voice = Voice()
  
  if (options.password == ""):
    voice.login()
  else:
    voice.login(passwd=options.password)

  if options.verbose:
    print "Sending msg to %s: '%s'" % (options.phoneNumber, options.message)
    
  voice.send_sms(options.phoneNumber, options.message)
  voice.logout()

if __name__ == "__main__":
  main()
