general: port management commands to new argument parsing (#16215)

This commit is contained in:
Frédéric Péters 2017-05-06 13:21:48 +02:00
parent 14497be115
commit a1d79e0be9
2 changed files with 15 additions and 14 deletions

View File

@ -15,7 +15,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import json
from optparse import make_option
import sys
from django.core.management.base import BaseCommand
@ -23,12 +22,12 @@ from django.core.management.base import BaseCommand
from combo.data.utils import export_site
class Command(BaseCommand):
args = ''
help = 'Export the site'
option_list = BaseCommand.option_list + (
make_option('--output', metavar='FILE', default=None,
help='name of a file to write output to'),
)
def add_arguments(self, parser):
parser.add_argument(
'--output', metavar='FILE', default=None,
help='name of a file to write output to')
def handle(self, *args, **options):
if options['output'] and options['output'] != '-':

View File

@ -15,7 +15,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import json
from optparse import make_option
import sys
from django.core.management.base import BaseCommand
@ -23,14 +22,17 @@ from django.core.management.base import BaseCommand
from combo.data.utils import import_site
class Command(BaseCommand):
args = '<filename>'
help = 'Import an exported site'
option_list = BaseCommand.option_list + (
make_option('--clean', action='store_true', default=False,
help='Clean site before importing'),
make_option('--if-empty', action='store_true', default=False,
help='Import only if site is empty'),
)
def add_arguments(self, parser):
parser.add_argument('filename', metavar='FILENAME', type=str,
help='name of file to import')
parser.add_argument(
'--clean', action='store_true', default=False,
help='Clean site before importing')
parser.add_argument(
'--if-empty', action='store_true', default=False,
help='Import only if site is empty')
def handle(self, filename, *args, **options):
if filename == '-':