mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Replace django-subcommand2 by custom code
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""Modoboa main management command."""
|
||||
|
||||
from subcommand.base import SubcommandCommand
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from .subcommands._export import ExportCommand
|
||||
from .subcommands._import import ImportCommand
|
||||
@@ -9,13 +9,13 @@ from .subcommands._mx import CheckMXRecords
|
||||
from .subcommands._repair import Repair
|
||||
|
||||
|
||||
class Command(SubcommandCommand):
|
||||
class Command(BaseCommand):
|
||||
"""Top management command for modoboa.
|
||||
|
||||
$ python manage.py modo
|
||||
"""
|
||||
|
||||
help = "Modoboa top management command." # NOQA:A003
|
||||
help = "Modoboa top management command."
|
||||
|
||||
subcommands = {
|
||||
"export": ExportCommand,
|
||||
@@ -24,3 +24,27 @@ class Command(SubcommandCommand):
|
||||
"manage_dkim_keys": ManageDKIMKeys,
|
||||
"repair": Repair,
|
||||
}
|
||||
|
||||
def add_arguments(self, parser):
|
||||
subparsers = parser.add_subparsers(
|
||||
dest='subcommand', title='subcommands'
|
||||
)
|
||||
# required argument is added in Python 3.7
|
||||
subparsers.required = True
|
||||
|
||||
for command_name, command_class in self.subcommands.items():
|
||||
command = command_class(self.stdout, self.stderr)
|
||||
command.style = self.style
|
||||
|
||||
subparser = subparsers.add_parser(
|
||||
command_name, help=command_class.help
|
||||
)
|
||||
# This is needed to output console friendly errors
|
||||
subparser.called_from_command_line = self._called_from_command_line
|
||||
|
||||
command.add_arguments(subparser)
|
||||
|
||||
subparser.set_defaults(command=command)
|
||||
|
||||
def execute(self, *args, **options):
|
||||
return options.pop('command').execute(*args, **options)
|
||||
|
||||
@@ -2,7 +2,6 @@ django>=2.0,<2.1
|
||||
django-braces==1.14.0
|
||||
django-ckeditor==5.8.0
|
||||
django-reversion==3.0.5
|
||||
django-subcommand2==0.1.1
|
||||
django-xforwardedfor-middleware==2.0
|
||||
|
||||
dj-database-url
|
||||
|
||||
Reference in New Issue
Block a user