Opened 5 years ago
Last modified 5 years ago
#32153 closed Bug
Support for list arguments inside exclusive required groups — at Initial Version
| Reported by: | Mark Gajdosik | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | dev |
| Severity: | Normal | Keywords: | call_command, exclusive group, nargs, error |
| Cc: | Hasan Ramezani | Triage Stage: | Ready for checkin |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Are there any plans to add support for the following?
from django.core.management import BaseCommand
class Command(BaseCommand):
def add_arguments(self, parser):
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--foo', nargs='+', type=int)
def handle(self, *args, **options):
pass
When calling the above using call_command:
call_command('call_command_test', foo=[1, 2, 3])
# Raises: django.core.management.base.CommandError: Error: one of the arguments --foo is required
call_command('call_command_test', '--foo=1', '--foo=2', '--foo=3')
# Option 'foo' will be of value [3]
I can't think of any workarounds. Thank you!
Note:
See TracTickets
for help on using tickets.