Switch to the option group pattern for API examples.

(imported from commit 67d0164df822a56f06d5f959297cc2efa9706001)
This commit is contained in:
Luke Faraone 2012-12-12 14:39:12 -05:00
parent ea27fbae11
commit f1d60f5417
6 changed files with 34 additions and 63 deletions

View file

@ -31,18 +31,14 @@ Prints out all the public streams in the realm.
Example: get-public-streams --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com
"""
parser = optparse.OptionParser(usage=usage)
parser.add_option('--site', default='https://humbughq.com')
parser.add_option('--api-key')
parser.add_option('--user')
(options, args) = parser.parse_args()
sys.path.append(path.join(path.dirname(__file__), '..'))
import humbug
client = humbug.Client(
email=options.user,
api_key=options.api_key,
verbose=True,
site=options.site)
parser = optparse.OptionParser(usage=usage)
parser.add_option_group(humbug.generate_option_group(parser))
(options, args) = parser.parse_args()
client = humbug.init_from_options(options)
print client.get_public_streams()

View file

@ -31,18 +31,13 @@ Prints out a list of the user's subscriptions.
Example: list-subscriptions --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com
"""
parser = optparse.OptionParser(usage=usage)
parser.add_option('--site', default='https://humbughq.com')
parser.add_option('--api-key')
parser.add_option('--user')
(options, args) = parser.parse_args()
sys.path.append(path.join(path.dirname(__file__), '..'))
import humbug
client = humbug.Client(
email=options.user,
api_key=options.api_key,
verbose=True,
site=options.site)
parser = optparse.OptionParser(usage=usage)
parser.add_option_group(humbug.generate_option_group(parser))
(options, args) = parser.parse_args()
client = humbug.init_from_options(options)
print client.list_subscriptions()

View file

@ -31,19 +31,14 @@ Prints out each message received by the indicated user.
Example: print-messages --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com
"""
parser = optparse.OptionParser(usage=usage)
parser.add_option('--site', default='https://humbughq.com')
parser.add_option('--api-key')
parser.add_option('--user')
(options, args) = parser.parse_args()
sys.path.append(path.join(path.dirname(__file__), '..'))
import humbug
client = humbug.Client(
email=options.user,
api_key=options.api_key,
verbose=True,
site=options.site)
parser = optparse.OptionParser(usage=usage)
parser.add_option_group(humbug.generate_option_group(parser))
(options, args) = parser.parse_args()
client = humbug.init_from_options(options)
def print_message(message):
print message

View file

@ -31,18 +31,13 @@ Prints out the next message received by the user.
Example: print-next-messages --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com
"""
parser = optparse.OptionParser(usage=usage)
parser.add_option('--site', default='https://humbughq.com')
parser.add_option('--api-key')
parser.add_option('--user')
(options, args) = parser.parse_args()
sys.path.append(path.join(path.dirname(__file__), '..'))
import humbug
client = humbug.Client(
email=options.user,
api_key=options.api_key,
verbose=True,
site=options.site)
parser = optparse.OptionParser(usage=usage)
parser.add_option_group(humbug.generate_option_group(parser))
(options, args) = parser.parse_args()
client = humbug.init_from_options(options)
print client.get_messages({})

View file

@ -31,20 +31,15 @@ Ensures the user is subscribed to the listed streams.
Example: subscribe --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com
"""
sys.path.append(path.join(path.dirname(__file__), '..'))
import humbug
parser = optparse.OptionParser(usage=usage)
parser.add_option('--api-key')
parser.add_option('--user')
parser.add_option('--site', default='https://humbughq.com')
parser.add_option_group(humbug.generate_option_group(parser))
parser.add_option('--streams', default='')
(options, args) = parser.parse_args()
sys.path.append(path.join(path.dirname(__file__), '..'))
import humbug
client = humbug.Client(
email=options.user,
api_key=options.api_key,
verbose=True,
site=options.site)
client = humbug.init_from_options(options)
if options.streams == "":
print >>sys.stderr, "Usage:", parser.usage

View file

@ -31,20 +31,15 @@ Ensures the user is not subscribed to the listed streams.
Example: unsubscribe --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com
"""
sys.path.append(path.join(path.dirname(__file__), '..'))
import humbug
parser = optparse.OptionParser(usage=usage)
parser.add_option('--api-key')
parser.add_option('--user')
parser.add_option('--site', default='https://humbughq.com')
parser.add_option_group(humbug.generate_option_group(parser))
parser.add_option('--streams', default='')
(options, args) = parser.parse_args()
sys.path.append(path.join(path.dirname(__file__), '..'))
import humbug
client = humbug.Client(
email=options.user,
api_key=options.api_key,
verbose=True,
site=options.site)
client = humbug.init_from_options(options)
if options.streams == "":
print >>sys.stderr, "Usage:", parser.usage