2017-11-16 00:43:27 +01:00
|
|
|
from argparse import ArgumentParser
|
2016-06-04 16:52:18 +02:00
|
|
|
from typing import Any
|
|
|
|
|
2017-08-08 15:07:03 +02:00
|
|
|
from zerver.lib.management import ZulipBaseCommand
|
2020-03-24 14:47:41 +01:00
|
|
|
from zerver.lib.streams import create_stream_if_needed
|
2013-10-19 15:28:59 +02:00
|
|
|
|
2020-01-14 21:59:46 +01: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")
|
2021-02-12 08:19:30 +01:00
|
|
|
parser.add_argument('stream_name', metavar='<stream name>', 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
|
|
|
|
|
2016-07-05 03:39:01 +02:00
|
|
|
stream_name = options['stream_name']
|
2020-06-29 23:31:25 +02:00
|
|
|
create_stream_if_needed(realm, stream_name, acting_user=None)
|