#28398: Allow management command invocation to suggest commands for mistyped
commands
-------------------------------------+-------------------------------------
     Reporter:  Vlada Macek          |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Core (Management     |                  Version:  1.11
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Someday/Maybe
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Shai Berger):

 * cc: Shai Berger (added)


Comment:

 I think Django should not try to be a shell helper -- shell completions do
 a pretty good job, and the use case you describe seems to be answered by
 {{{
 $ ./manage.py help | grep passw
 }}}
 That said, I can see why people would like to have such functionality --
 or even more sophisticated options -- built into their `manage.py`. And
 it's a bit of a shame that they have to patch Django to do that. So, in my
 opinion, instead of taking the current simple patch, we should think how
 to make command invocation extensible.

 And having written that, I just thought of this:

 Step 1: Add a new management command `enhanced_manage` which takes all its
 arguments and options, does whatever it likes (e.g. make sure the first
 arg is actually the name of an existing command, and if not suggests
 alternatives), and if all is well ends with `call_command()` to execute
 the command given;  so that you can get your functionality by running
 `manage.py enhanced_manage passw`, or run the full command as `manage.py
 enhanced_manage changepassword username`

 Step 2: In your project, edit the file `manage.py`; replace the line
 {{{
     execute_from_command_line(sys.argv)
 }}}
 with
 {{{
     execute_from_command_line(['enhanced_manage'] + sys.argv)
 }}}
 And - tada! extensible command execution, no Django patching required. I
 suppose this way has some limitations I haven't thought about, and it may
 seem like a lot of work compared to your simple patch, but as Tim said
 (and you agreed) such features tend to evolve and become more complicated,
 and this way makes it possible for them to evolve outside of core, without
 even waiting for the next Django release.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28398#comment:4>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.89ce876eabd1e1a21e0b51e336f57810%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to