Add --stream option to print-messages, print-next-message API examples

(imported from commit aeaf8a111759de59ba87fc7014be86bd13810271)
This commit is contained in:
Reid Barton 2013-01-15 18:21:13 -05:00
parent ed29f22069
commit 3c1f08c394
2 changed files with 14 additions and 6 deletions

View File

@ -25,9 +25,9 @@ import sys
from os import path
import optparse
usage = """print-messages --user=<email address> [options]
usage = """print-messages --user=<email address> [--stream=<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)

View File

@ -25,9 +25,9 @@ import sys
from os import path
import optparse
usage = """print-next-message --user=<email address> [options]
usage = """print-next-message --user=<email address> [--stream=<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)