diff --git a/zulip/zulip/__init__.py b/zulip/zulip/__init__.py index f632cf3..2941e4c 100644 --- a/zulip/zulip/__init__.py +++ b/zulip/zulip/__init__.py @@ -897,6 +897,9 @@ class Client(object): def get_alert_words(self): # type: () -> Dict[str, Any] + ''' + See examples/alert-words for example usage. + ''' return self.call_endpoint( url='users/me/alert_words', method='GET' @@ -904,6 +907,9 @@ class Client(object): def add_alert_words(self, alert_words): # type: (List[str]) -> Dict[str, Any] + ''' + See examples/alert-words for example usage. + ''' return self.call_endpoint( url='users/me/alert_words', method='POST', @@ -914,6 +920,9 @@ class Client(object): def remove_alert_words(self, alert_words): # type: (List[str]) -> Dict[str, Any] + ''' + See examples/alert-words for example usage. + ''' return self.call_endpoint( url='users/me/alert_words', method='DELETE', diff --git a/zulip/zulip/examples/alert-words b/zulip/zulip/examples/alert-words new file mode 100755 index 0000000..b1e6d1c --- /dev/null +++ b/zulip/zulip/examples/alert-words @@ -0,0 +1,31 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import argparse + +import zulip + +usage = """alert-words (get | add | remove) [words] [options] + + +Example: alert-words get +Example: alert-words add foo bar +Example: alert-words remove banana +""" + + +parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage)) +parser.add_argument('operation', choices=['get', 'add', 'remove'], type=str) +parser.add_argument('words', type=str, nargs='*') +options = parser.parse_args() + +client = zulip.init_from_options(options) + +if options.operation == 'get': + result = client.get_alert_words() +elif options.operation == 'add': + result = client.add_alert_words(options.words) +elif options.operation == 'remove': + result = client.remove_alert_words(options.words) + +print(result)