2013-10-19 15:28:59 +02:00
|
|
|
|
2017-11-16 00:43:27 +01:00
|
|
|
import sys
|
|
|
|
from argparse import ArgumentParser
|
2016-06-04 16:52:18 +02:00
|
|
|
from typing import Any
|
|
|
|
|
2017-01-30 06:28:33 +01:00
|
|
|
from zerver.lib.actions import create_stream_if_needed
|
2017-08-08 15:07:03 +02:00
|
|
|
from zerver.lib.management import ZulipBaseCommand
|
2017-11-16 00:43:27 +01:00
|
|
|
from zerver.lib.str_utils import force_text
|
2013-10-19 15:28:59 +02:00
|
|
|
|
2017-08-08 15:07:03 +02:00
|
|
|
class Command(ZulipBaseCommand):
|
2013-10-19 15:28:59 +02:00
|
|
|
help = """Create a stream, and subscribe all active users (excluding bots).
|
|
|
|
|
|
|
|
This should be used for TESTING only, unless you understand the limitations of
|
2015-08-21 02:10:41 +02:00
|
|
|
the command."""
|
2013-10-19 15:28:59 +02:00
|
|
|
|
2017-10-26 11:35:57 +02:00
|
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
2017-08-08 15:07:03 +02:00
|
|
|
self.add_realm_args(parser, True, "realm in which to create the stream")
|
2015-08-21 02:10:41 +02:00
|
|
|
parser.add_argument('stream_name', metavar='<stream name>', type=str,
|
|
|
|
help='name of stream to create')
|
2013-10-19 15:28:59 +02:00
|
|
|
|
2017-10-26 11:35:57 +02:00
|
|
|
def handle(self, *args: Any, **options: str) -> None:
|
2017-08-08 15:07:03 +02:00
|
|
|
realm = self.get_realm(options)
|
2017-09-26 01:25:39 +02:00
|
|
|
assert realm is not None # Should be ensured by parser
|
|
|
|
|
2013-10-19 15:28:59 +02:00
|
|
|
encoding = sys.getfilesystemencoding()
|
2016-07-05 03:39:01 +02:00
|
|
|
stream_name = options['stream_name']
|
2017-01-30 06:28:33 +01:00
|
|
|
create_stream_if_needed(realm, force_text(stream_name, encoding))
|