diff --git a/examples/get-public-streams b/examples/get-public-streams index 3ecd46d..0ea9d16 100755 --- a/examples/get-public-streams +++ b/examples/get-public-streams @@ -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() diff --git a/examples/list-subscriptions b/examples/list-subscriptions index f32743b..c460f5e 100755 --- a/examples/list-subscriptions +++ b/examples/list-subscriptions @@ -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() diff --git a/examples/print-messages b/examples/print-messages index 570fd1b..8dac678 100755 --- a/examples/print-messages +++ b/examples/print-messages @@ -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 diff --git a/examples/print-next-message b/examples/print-next-message index 968b707..396f501 100755 --- a/examples/print-next-message +++ b/examples/print-next-message @@ -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({}) diff --git a/examples/subscribe b/examples/subscribe index cedf426..a5d7c97 100755 --- a/examples/subscribe +++ b/examples/subscribe @@ -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 diff --git a/examples/unsubscribe b/examples/unsubscribe index 609e4ca..e73be0b 100755 --- a/examples/unsubscribe +++ b/examples/unsubscribe @@ -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