2013-08-21 23:22:10 +02:00
|
|
|
|
2017-11-16 00:43:27 +01:00
|
|
|
import sys
|
2016-06-04 16:52:18 +02:00
|
|
|
from argparse import ArgumentParser
|
2017-11-16 00:43:27 +01:00
|
|
|
from typing import Any
|
2013-08-21 23:22:10 +02:00
|
|
|
|
|
|
|
from zerver.lib.actions import do_rename_stream
|
2017-08-07 22:14:42 +02:00
|
|
|
from zerver.lib.management import ZulipBaseCommand
|
|
|
|
from zerver.models import get_stream
|
2013-08-21 23:22:10 +02:00
|
|
|
|
2017-08-07 22:14:42 +02:00
|
|
|
class Command(ZulipBaseCommand):
|
2015-08-21 02:10:41 +02:00
|
|
|
help = """Change the stream name for a realm."""
|
2013-08-21 23:22:10 +02:00
|
|
|
|
2017-10-26 11:35:57 +02:00
|
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
2015-08-21 02:10:41 +02:00
|
|
|
parser.add_argument('old_name', metavar='<old name>', type=str,
|
|
|
|
help='name of stream to be renamed')
|
|
|
|
parser.add_argument('new_name', metavar='<new name>', type=str,
|
|
|
|
help='new name to rename the stream to')
|
2017-08-07 22:14:42 +02:00
|
|
|
self.add_realm_args(parser, True)
|
2013-08-21 23:22:10 +02:00
|
|
|
|
2017-10-26 11:35:57 +02:00
|
|
|
def handle(self, *args: Any, **options: str) -> None:
|
2017-08-07 22:14:42 +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
|
2015-08-21 02:10:41 +02:00
|
|
|
old_name = options['old_name']
|
|
|
|
new_name = options['new_name']
|
2013-08-21 23:22:10 +02:00
|
|
|
|
2018-11-27 20:24:23 +01:00
|
|
|
stream = get_stream(old_name, realm)
|
|
|
|
do_rename_stream(stream, new_name)
|