#32153: Support for list arguments inside exclusive required groups -------------------------------------+------------------------------------- Reporter: Mark Gajdosik | Owner: nobody Type: Uncategorized | Status: new Component: Uncategorized | Version: master Severity: Normal | Resolution: Keywords: call_command, | Triage Stage: exclusive group, nargs, error | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Description changed by Mark Gajdosik:
Old 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! New 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 other than setting `type=str` (somehow, that works fine) and coercing manually. Thank you! -- -- Ticket URL: <https://code.djangoproject.com/ticket/32153#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/070.eedb77ab1dcac8d1bd2105c57cdd129a%40djangoproject.com.