e30b3b094b
Generated by `pyupgrade --py3-plus --keep-percent-format` followed by manual indentation fixes. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
41 lines
1.2 KiB
Python
Executable file
41 lines
1.2 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
|
|
import zulip
|
|
|
|
usage = """edit-stream --stream-id <stream_id>
|
|
[--description <new_description> --new-name <new_name>
|
|
--private --announcement-only --history-public-to-subscribers]
|
|
|
|
Example: edit-stream --stream-id=42 --description="A city in Italy." \
|
|
--new-name="Verona" --private
|
|
Example: edit-stream --stream-id=3 --history-public-to-subscribers
|
|
"""
|
|
|
|
|
|
def quote(string):
|
|
# type: (str) -> str
|
|
return '"{}"'.format(string)
|
|
|
|
|
|
parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage))
|
|
parser.add_argument('--stream-id', type=int, required=True)
|
|
parser.add_argument('--description')
|
|
parser.add_argument('--new-name')
|
|
parser.add_argument('--private', action='store_true')
|
|
parser.add_argument('--announcement-only', action='store_true')
|
|
parser.add_argument('--history-public-to-subscribers', action='store_true')
|
|
options = parser.parse_args()
|
|
|
|
client = zulip.init_from_options(options)
|
|
|
|
print(client.update_stream({
|
|
'stream_id': options.stream_id,
|
|
'description': quote(options.description),
|
|
'new_name': quote(options.new_name),
|
|
'is_private': options.private,
|
|
'is_announcement_only': options.announcement_only,
|
|
'history_public_to_subscribers': options.history_public_to_subscribers
|
|
}))
|