From 96cd0fc325ba234ae8135f69a8ec3c601dc9541d Mon Sep 17 00:00:00 2001 From: Reid Barton Date: Tue, 15 Jan 2013 18:21:13 -0500 Subject: [PATCH] Add --stream option to print-messages, print-next-message API examples (imported from commit aeaf8a111759de59ba87fc7014be86bd13810271) --- examples/print-messages | 10 +++++++--- examples/print-next-message | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/examples/print-messages b/examples/print-messages index 8dac678..a20dc19 100755 --- a/examples/print-messages +++ b/examples/print-messages @@ -25,9 +25,9 @@ import sys from os import path import optparse -usage = """print-messages --user= [options] +usage = """print-messages --user= [--stream=] [options] -Prints out each message received by the indicated user. +Prints out each message received by the indicated user, or on the indicated public stream. Example: print-messages --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com """ @@ -36,6 +36,7 @@ import humbug parser = optparse.OptionParser(usage=usage) parser.add_option_group(humbug.generate_option_group(parser)) +parser.add_option('--stream', default=None) (options, args) = parser.parse_args() client = humbug.init_from_options(options) @@ -43,4 +44,7 @@ client = humbug.init_from_options(options) def print_message(message): print message -client.call_on_each_message(print_message) +get_messages_options = {} +if options.stream is not None: + get_messages_options['stream_name'] = options.stream +client.call_on_each_message(print_message, get_messages_options) diff --git a/examples/print-next-message b/examples/print-next-message index 396f501..e0b3294 100755 --- a/examples/print-next-message +++ b/examples/print-next-message @@ -25,9 +25,9 @@ import sys from os import path import optparse -usage = """print-next-message --user= [options] +usage = """print-next-message --user= [--stream=] [options] -Prints out the next message received by the user. +Prints out the next message received by the indicated user, or on the indicated public stream. Example: print-next-messages --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com """ @@ -36,8 +36,12 @@ import humbug parser = optparse.OptionParser(usage=usage) parser.add_option_group(humbug.generate_option_group(parser)) +parser.add_option('--stream', default=None) (options, args) = parser.parse_args() client = humbug.init_from_options(options) -print client.get_messages({}) +get_messages_options = {} +if options.stream is not None: + get_messages_options['stream_name'] = options.stream +print client.get_messages(get_messages_options)