mirror of https://github.com/zulip/zulip.git
Add --stream option to print-messages, print-next-message API examples
(imported from commit aeaf8a111759de59ba87fc7014be86bd13810271)
This commit is contained in:
parent
ed29f22069
commit
3c1f08c394
|
@ -25,9 +25,9 @@ import sys
|
||||||
from os import path
|
from os import path
|
||||||
import optparse
|
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
|
Example: print-messages --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com
|
||||||
"""
|
"""
|
||||||
|
@ -36,6 +36,7 @@ import humbug
|
||||||
|
|
||||||
parser = optparse.OptionParser(usage=usage)
|
parser = optparse.OptionParser(usage=usage)
|
||||||
parser.add_option_group(humbug.generate_option_group(parser))
|
parser.add_option_group(humbug.generate_option_group(parser))
|
||||||
|
parser.add_option('--stream', default=None)
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
client = humbug.init_from_options(options)
|
client = humbug.init_from_options(options)
|
||||||
|
@ -43,4 +44,7 @@ client = humbug.init_from_options(options)
|
||||||
def print_message(message):
|
def print_message(message):
|
||||||
print 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)
|
||||||
|
|
|
@ -25,9 +25,9 @@ import sys
|
||||||
from os import path
|
from os import path
|
||||||
import optparse
|
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
|
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 = optparse.OptionParser(usage=usage)
|
||||||
parser.add_option_group(humbug.generate_option_group(parser))
|
parser.add_option_group(humbug.generate_option_group(parser))
|
||||||
|
parser.add_option('--stream', default=None)
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
client = humbug.init_from_options(options)
|
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)
|
||||||
|
|
Loading…
Reference in New Issue