tests/user_commands/management/commands/common_args.py
raw| 1 | from argparse import ArgumentError |
| 2 | |
| 3 | from django.core.management.base import BaseCommand, CommandError |
| 4 | |
| 5 | |
| 6 | class Command(BaseCommand): |
| 7 | def add_arguments(self, parser): |
| 8 | try: |
| 9 | parser.add_argument("--version", action="version", version="A.B.C") |
| 10 | except ArgumentError: |
| 11 | pass |
| 12 | else: |
| 13 | raise CommandError("--version argument does no yet exist") |
| 14 | |
| 15 | def handle(self, *args, **options): |
| 16 | return "Detected that --version already exists" |