mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-27 03:05:39 +01:00
Django plugin. Added functionality to dynamically generate a list of commands manage.py
This commit is contained in:
parent
96e4e5dd03
commit
c24f949394
1 changed files with 35 additions and 9 deletions
|
|
@ -171,9 +171,28 @@ _managepy-validate() {
|
||||||
$nul_args && ret=0
|
$nul_args && ret=0
|
||||||
}
|
}
|
||||||
|
|
||||||
_managepy-commands() {
|
_managepy-commands(){
|
||||||
local -a commands
|
local -a commands
|
||||||
|
|
||||||
|
if [[ "$DJANGO_PLUGIN" = "extend" ]]; then
|
||||||
|
local line
|
||||||
|
_call_program help-command "python -c \"
|
||||||
|
import sys;import os;import logging;
|
||||||
|
logging.disable(logging.INFO)
|
||||||
|
from django.conf import settings
|
||||||
|
import django
|
||||||
|
django.setup()
|
||||||
|
from django.core.management import get_commands, load_command_class;
|
||||||
|
rs = ''
|
||||||
|
for command, app in sorted(get_commands().items(), key=lambda e: (e[1], e[0])):
|
||||||
|
try:
|
||||||
|
rs += ':'.join((command, ' '.join(load_command_class(app, command).help.strip().splitlines())[:100]))
|
||||||
|
rs += os.linesep
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
sys.stdout.write(rs)\"" \
|
||||||
|
| while read -A line; do commands=("$line" $commands) done
|
||||||
|
else
|
||||||
commands=(
|
commands=(
|
||||||
'adminindex:prints the admin-index template snippet for the given app name(s).'
|
'adminindex:prints the admin-index template snippet for the given app name(s).'
|
||||||
'createcachetable:creates the table needed to use the SQL cache backend.'
|
'createcachetable:creates the table needed to use the SQL cache backend.'
|
||||||
|
|
@ -205,23 +224,30 @@ _managepy-commands() {
|
||||||
'testserver:Runs a development server with data from the given fixture(s).'
|
'testserver:Runs a development server with data from the given fixture(s).'
|
||||||
'validate:Validates all installed models.'
|
'validate:Validates all installed models.'
|
||||||
)
|
)
|
||||||
|
fi
|
||||||
_describe -t commands 'manage.py command' commands && ret=0
|
_describe -t commands 'manage.py command' commands && ret=0
|
||||||
}
|
}
|
||||||
|
|
||||||
_applist() {
|
_applist() {
|
||||||
local line
|
local line
|
||||||
local -a apps
|
local -a apps
|
||||||
_call_program help-command "python -c \"import os.path as op, re, django.conf, sys;\\
|
_call_program help-command "python -c \"
|
||||||
bn=op.basename(op.abspath(op.curdir));[sys\\
|
import os, re, django.conf, sys, logging;
|
||||||
.stdout.write(str(re.sub(r'^%s\.(.*?)$' %
|
logging.disable(logging.INFO)
|
||||||
bn, r'\1', i)) + '\n') for i in django.conf.settings.\\
|
sys.stdout.write(os.linesep.join([i for i in django.conf.settings.INSTALLED_APPS]) + os.linesep)\"" \
|
||||||
INSTALLED_APPS if re.match(r'^%s' % bn, i)]\"" \
|
|
||||||
| while read -A line; do apps=($line $apps) done
|
| while read -A line; do apps=($line $apps) done
|
||||||
_values 'Application' $apps && ret=0
|
_values 'Application' $apps && ret=0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
activate_django_settings() {
|
||||||
|
if [[ -a "settings" ]]; then
|
||||||
|
export DJANGO_SETTINGS_MODULE="settings"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
_managepy() {
|
_managepy() {
|
||||||
|
autoload activate_django_settings
|
||||||
|
activate_django_settings
|
||||||
local curcontext=$curcontext ret=1
|
local curcontext=$curcontext ret=1
|
||||||
|
|
||||||
if ((CURRENT == 2)); then
|
if ((CURRENT == 2)); then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue