integrations/google: Upgrade to argparse.

This commit is contained in:
Eeshan Garg 2017-08-01 19:01:00 -02:30
parent 59c750707a
commit 780ccb392e

View file

@ -8,7 +8,7 @@ import dateutil.parser
import httplib2 import httplib2
import itertools import itertools
import logging import logging
import optparse import argparse
import os import os
import pytz import pytz
from six.moves import urllib from six.moves import urllib
@ -40,9 +40,9 @@ sent = set() # type: Set[Tuple[int, datetime.datetime]]
sys.path.append(os.path.dirname(__file__)) sys.path.append(os.path.dirname(__file__))
parser = optparse.OptionParser(r""" parser = zulip.add_default_arguments(argparse.ArgumentParser(r"""
%prog \ google-calendar \
--user foo@zulip.com \ --user foo@zulip.com \
--calendar calendarID@example.calendar.google.com --calendar calendarID@example.calendar.google.com
@ -55,10 +55,10 @@ parser = optparse.OptionParser(r"""
revealed to local users through the command line. revealed to local users through the command line.
Depends on: google-api-python-client Depends on: google-api-python-client
""") """))
parser.add_option('--interval', parser.add_argument('--interval',
dest='interval', dest='interval',
default=30, default=30,
type=int, type=int,
@ -66,16 +66,14 @@ parser.add_option('--interval',
help='Minutes before event for reminder [default: 30]', help='Minutes before event for reminder [default: 30]',
metavar='MINUTES') metavar='MINUTES')
parser.add_option('--calendar', parser.add_argument('--calendar',
dest = 'calendarID', dest = 'calendarID',
default = 'primary', default = 'primary',
type = str, type = str,
action = 'store', action = 'store',
help = 'Calendar ID for the calendar you want to receive reminders from.') help = 'Calendar ID for the calendar you want to receive reminders from.')
parser.add_option_group(zulip.generate_option_group(parser)) options = parser.parse_args()
(options, args) = parser.parse_args()
if not (options.zulip_email): if not (options.zulip_email):
parser.error('You must specify --user') parser.error('You must specify --user')