#33205: call_command fails when required mutually exclusive group arguments use 
the
same `dest`
-----------------------------------------+------------------------
               Reporter:  Peter Law      |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Uncategorized  |        Version:  3.2
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 I have a command which accepts two different ways to specify a time --
 either as a timestamp or as a duration in the future:
 {{{
 pause (--for duration | --until time)
 }}}

 {{{#!python
 class Command(BaseCommand):
     def add_arguments(self, parser) -> None:
         group = parser.add_mutually_exclusive_group(required=True)
         group.add_argument('--for', dest='until', action='store',
 type=parse_duration_to_time)
         group.add_argument('--until', action='store', type=parse_time)

     def handle(self, until: datetime, **_):
         pass
 }}}


 This works fine on the command line, however there doesn't seem to be a
 way to make this work through `call_command`. Specifically there are two
 sides to the failure:
 - while I can provide an `until` value (as a string, which is processed by
 `parse_time`) there is no mechanism to pass a `for` value if that's how I
 want to spell the input
 - the `for` value is always required and attempts to parse the (string)
 `until` value passed, which then errors since the input formats are very
 different

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33205>
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/053.b7bde51b8d74330c4899df9e1d26929d%40djangoproject.com.

Reply via email to