Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug#517672: Complete custom/unknown Django management commands



On Sun, Mar 01, 2009 at 11:35:07AM +0000, Chris Lamb wrote:
> The current completion script for Django's manage.py files hardcodes the
> possible subcommands. However, custom management commands are widespread, so
> it would be nice to at least allow completion.
> 
> Patch attached.

Index: Completion/Unix/Command/_django
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_django,v
retrieving revision 1.1
diff -u -r1.1 _django
--- Completion/Unix/Command/_django	28 Sep 2008 19:38:00 -0000	1.1
+++ Completion/Unix/Command/_django	1 Mar 2009 16:10:12 -0000
@@ -57,6 +57,15 @@
       "testserver:run a development server with data from the given fixture(s)"
       "validate:validate all installed modules"
     )
+
+    for cmd in $(./manage.py --help 2>&1 >/dev/null | \
+        awk -vdrop=1 '{ if (!drop) print substr($0, 3) } /^Available subcommands/ { drop=0 }')
+    do
+        if ! echo $subcommands | grep -qs "${cmd}:"
+        then
+            subcommands+=($cmd)
+        fi
+    done
     
     _describe -t subcommands 'django admin subcommand' subcommands && ret=0
     ;;



Messages sorted by: Reverse Date, Date, Thread, Author