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

@@ -4,26 +4,26 @@ from __future__ import print_function
from typing import Any
from optparse import make_option
from django.core.management.base import BaseCommand
from django.core.management.base import BaseCommand, CommandParser
from zerver.models import get_realm, Message, Realm, Stream, Recipient
import datetime
import time
class Command(BaseCommand):
default_cutoff = time.time() - 60 * 60 * 24 * 30 # 30 days.
def add_arguments(self, parser):
# type: (CommandParser) -> None
default_cutoff = time.time() - 60 * 60 * 24 * 30 # 30 days.
parser.add_argument('--domain',
dest='domain',
type=str,
help='The domain whose public streams you want to dump.')
option_list = BaseCommand.option_list + (
make_option('--domain',
dest='domain',
type='str',
help='The domain whose public streams you want to dump.'),
make_option('--since',
dest='since',
type='int',
default=default_cutoff,
help='The time in epoch since from which to start the dump.')
)
parser.add_argument('--since',
dest='since',
type=int,
default=default_cutoff,
help='The time in epoch since from which to start the dump.')
def handle(self, *args, **options):
# type: (*Any, **Any) -> None