1
0
mirror of https://github.com/django/django.git synced 2024-12-25 10:35:48 +00:00
django/tests/user_commands/management/commands/required_constant_option.py

21 lines
770 B
Python
Raw Normal View History

from django.core.management.base import BaseCommand
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument(
'--append_const',
action='append_const',
const=42,
required=True,
)
parser.add_argument('--const', action='store_const', const=31, required=True)
parser.add_argument('--count', action='count', required=True)
parser.add_argument('--flag_false', action='store_false', required=True)
parser.add_argument('--flag_true', action='store_true', required=True)
def handle(self, *args, **options):
for option, value in options.items():
if value is not None:
self.stdout.write('%s=%s' % (option, value))