[Django] #28398: manage.py should offer candidate commands via substring search

13 views
Skip to the first unread message

Django

unread,
14 Jul 2017, 10:15:4214/07/2017
to django-...@googlegroups.com
#28398: manage.py should offer candidate commands via substring search
-------------------------------------+-------------------------------------
Reporter: Vlada | Owner: nobody
Macek |
Type: New | Status: new
feature |
Component: Core | Version: 1.11
(Management commands) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
Too often I can't remember the full mgmt command name, but can remember a
part of it.

A little enhancement would save me time.

Attaching a screenshot and a patch. Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/28398>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
14 Jul 2017, 10:16:1114/07/2017
to django-...@googlegroups.com
#28398: manage.py should offer candidate commands via substring search
-------------------------------------+-------------------------------------
Reporter: Vlada Macek | Owner: nobody
Type: New feature | Status: new
Component: Core (Management | Version: 1.11
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Vlada Macek):

* Attachment "autocomplete.png" added.

screenshot

Django

unread,
14 Jul 2017, 10:16:2714/07/2017
to django-...@googlegroups.com
#28398: manage.py should offer candidate commands via substring search
-------------------------------------+-------------------------------------
Reporter: Vlada Macek | Owner: nobody
Type: New feature | Status: new
Component: Core (Management | Version: 1.11
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Vlada Macek):

* Attachment "candidate-commands.diff" added.

a patch

Django

unread,
14 Jul 2017, 14:05:2114/07/2017
to django-...@googlegroups.com
#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 Tim Graham):

* needs_better_patch: 0 => 1
* stage: Unreviewed => Someday/Maybe
* easy: 1 => 0


Comment:

I wonder if we could do something smarter than a substring search. Perhaps
there are other libraries we could borrow ideas from. It would be
appropriate to write the DevelopersMailingList to get feedback.

I wonder if this isn't somewhat redundant to the
[https://docs.djangoproject.com/en/dev/ref/django-admin/#bash-completion
bash completion script] though.

--
Ticket URL: <https://code.djangoproject.com/ticket/28398#comment:1>

Django

unread,
14 Jul 2017, 18:57:5114/07/2017
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------

Comment (by Vlada Macek):

Thanks for considering. I don't see this feature to require a considerable
planning to be completed on first shot. It could evolve.
I was thinking about similarity string search etc., but ended up with the
simplest change possible, a substring search. This version would start to
help me.
Okay, adding colors wasn't the simplest, but just nice and can be removed.
I like simple clever hints to the user like this.
Bash completion is neat, but not always available and installed.

--
Ticket URL: <https://code.djangoproject.com/ticket/28398#comment:2>

Django

unread,
14 Jul 2017, 20:51:0914/07/2017
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

Since all features have development and maintenance costs, I'd like for
others to confirm it's worth the effort before we commit to doing it.

--
Ticket URL: <https://code.djangoproject.com/ticket/28398#comment:3>

Django

unread,
15 Jul 2017, 15:34:0315/07/2017
to django-...@googlegroups.com
#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

unread,
30 Jul 2017, 10:43:0630/07/2017
to django-...@googlegroups.com
#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 Tom):

* cc: Tom (added)


Comment:

I think this is definitely worth pursuing - it's not that complicated to
add and it helps out beginners who are new to the whole manage.py
experience. I think people are perhaps over-thinking this: providing 'did
you mean' suggestions for typos has a lot of prior art including `git` and
the default bash on Ubuntu and shouldn't be complicated or require any
interaction.

Simply printing out potential candidate commands when the user makes a
typo is a quick and easy win IMO. Yes, users could use grep, but that
assumes that they are familiar with such tools and are on a system that
provides them. Plus learning a new tool like manage.py can be quite hard
at the beginning and there is definitely a selection bias here of people
who are familiar with Django and unix tooling in general. I wouldn't find
this feature useful at all, but someone who is starting out with Django
may.

--
Ticket URL: <https://code.djangoproject.com/ticket/28398#comment:5>

Django

unread,
16 Feb 2018, 13:23:1016/02/2018
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------

Comment (by Tom Forbes):

Potential PR: https://github.com/django/django/pull/9703

--
Ticket URL: <https://code.djangoproject.com/ticket/28398#comment:6>

Django

unread,
19 Feb 2018, 06:17:2319/02/2018
to django-...@googlegroups.com
#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: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* needs_better_patch: 1 => 0
* stage: Someday/Maybe => Ready for checkin


Comment:

Tom's new PR looks great.

--
Ticket URL: <https://code.djangoproject.com/ticket/28398#comment:7>

Django

unread,
21 Feb 2018, 09:01:0821/02/2018
to django-...@googlegroups.com
#28398: Allow management command invocation to suggest commands for mistyped
commands
-------------------------------------+-------------------------------------
Reporter: Vlada Macek | Owner: nobody
Type: New feature | Status: closed

Component: Core (Management | Version: 1.11
commands) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"33ac036a6bcab64ef93d0185f7b55eb57e559d6e" 33ac036a]:
{{{
#!CommitTicketReference repository=""
revision="33ac036a6bcab64ef93d0185f7b55eb57e559d6e"
Fixed #28398 -- Added suggestions for mistyped management commands.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28398#comment:8>

Reply all
Reply to author
Forward
0 new messages