Django 1.10: Use add_argument for options in BaseCommand.

This commit is contained in:
Umair Khan
2016-11-03 14:22:19 +05:00
committed by Tim Abbott
parent d3a4fa3e94
commit 682aa1f298
18 changed files with 284 additions and 240 deletions

View File

@@ -6,7 +6,7 @@ from typing import Any
from argparse import ArgumentParser
from optparse import make_option
from django.core.management.base import BaseCommand
from django.core.management.base import BaseCommand, CommandParser
from zerver.lib.actions import bulk_remove_subscriptions
from zerver.models import Realm, UserProfile, get_realm, get_stream, \
@@ -15,25 +15,29 @@ from zerver.models import Realm, UserProfile, get_realm, get_stream, \
class Command(BaseCommand):
help = """Remove some or all users in a realm from a stream."""
option_list = BaseCommand.option_list + (
make_option('-d', '--domain',
dest='domain',
type='str',
help='The name of the realm in which you are removing people.'),
make_option('-s', '--stream',
dest='stream',
type='str',
help='A stream name.'),
make_option('-u', '--users',
dest='users',
type='str',
help='A comma-separated list of email addresses.'),
make_option('-a', '--all-users',
dest='all_users',
action="store_true",
default=False,
help='Remove all users in this realm from this stream.'),
)
def add_arguments(self, parser):
# type: (CommandParser) -> None
parser.add_argument('-d', '--domain',
dest='domain',
type=str,
help='The name of the realm in which you are '
'removing people.')
parser.add_argument('-s', '--stream',
dest='stream',
type=str,
help='A stream name.')
parser.add_argument('-u', '--users',
dest='users',
type=str,
help='A comma-separated list of email addresses.')
parser.add_argument('-a', '--all-users',
dest='all_users',
action="store_true",
default=False,
help='Remove all users in this realm from this stream.')
def handle(self, **options):
# type: (*Any, **Any) -> None