Add drush completion, init commit
This commit is contained in:
parent
dae8cb844a
commit
75b4c450d5
|
@ -0,0 +1,134 @@
|
|||
#compdef drush
|
||||
# ------------------------------------------------------------------------------
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
# Completion script for Drush (http://drush.ws).
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Vasily Kraev (https://github.com/vasilykraev)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# TODO
|
||||
# commands: ard arr devel dre
|
||||
# features
|
||||
# move global args to separate array, use compadd
|
||||
|
||||
_drush() {
|
||||
local curcontext='$curcontext' state line cmds ret=1
|
||||
integer NORMARG
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
'(--*)'{--version,--version}'[Show drush version.]' \
|
||||
'(- *)'{-d,--debug}'[Display even more information, including internal messages.]' \
|
||||
'(- *)'{-v,--verbose}'[Display extra information about the command.]' \
|
||||
'(- *)'{-y,--yes}'[Assume "yes" as answer to all prompts.]' \
|
||||
'(- *)'{-n,--no}'[Assume "no" as answer to all prompts.]' \
|
||||
'(- *)'{-s,--simulate}'[Simulate all relevant actions (dont actually change the system).]' \
|
||||
'(- *)'{-r,--root=}'[Drupal root directory to use (default: current directory).]' \
|
||||
'(- *)'{-l,--uri=}'[URI of the drupal site to use (only needed in multisite environments or when running on an alternate port).]' \
|
||||
'1: :->cmds' \
|
||||
'*::arg:->args' \
|
||||
&& ret=0
|
||||
|
||||
case $state in
|
||||
cmds)
|
||||
_values 'drush command' \
|
||||
'(archive-dump)'{archive-dump,ard,arb}'[Backup your code, files, and database into a single file.]' \
|
||||
'(archive-restore)'{archive-restore,arr}'[Expand a site archive into a Drupal web site.]' \
|
||||
'(cache-clear)'{cache-clear,cc}'[Clear a specific cache, or all drupal caches.]' \
|
||||
'(core-status)'{core-status,status,st}'[Provides a birds-eye view of the current Drupal installation, if any.]' \
|
||||
'(core-cron)'{core-cron,cron}'[Run all cron hooks in all active modules for specified site.]' \
|
||||
'(core-execute)'{core-execute,exec}'[Execute a shell command. Usually used with a site alias.]' \
|
||||
'(drupal-directory)'{drupal-directory,dd}'[Return the filesystem path for modules/themes and other key folders.]' \
|
||||
'help[Print this help message.]' \
|
||||
'image-flush[Flush all derived images for a given style.]' \
|
||||
'(site-alias)'{site-alias,sa}'[Print an alias record.]' \
|
||||
'(site-install)'{site-install,si}'[Install Drupal along with modules/themes/configuration using the specified install profile.]' \
|
||||
'test-clean[Clean temporary tables and files.]' \
|
||||
'test-run[Run tests. Note that you must use the --uri option.]' \
|
||||
'(updatedb)'{updatedb,updb}'[Apply any database updates required (as with running update.php).]' \
|
||||
'(variable-delete)'{variable-delete,vdel}'[Delete a variable.]' \
|
||||
'(variable-get)'{variable-get,vget}'[Get a list of some or all site variables and values.]' \
|
||||
'(variable-set)'{variable-set,vset}'[Set a variable.]' \
|
||||
'(pm-list)'{pm-list,pml}'[Show a list of available extensions (modules and themes).]' \
|
||||
'(pm-disable)'{pm-disable,dis}'[Disable one or more extensions (modules or themes). Disable dependant extensions as well.]' \
|
||||
'(pm-download)'{pm-download,dl}'[Download projects from drupal.org or other sources.]' \
|
||||
'(pm-enable)'{pm-enable,en}'[Enable one or more extensions (modules or themes). Enable dependant extensions as well.]' \
|
||||
'pm-uninstall[Uninstall one or more modules.]' \
|
||||
'pm-update[Update Drupal core and contrib projects and apply any pending database updates (Same as pm-updatecode + updatedb).]' \
|
||||
'(sql-cli)'{sql-cli,sqlc}'[Open a SQL command-line interface using Drupals credentials.]' \
|
||||
'sql-drop[Drop all tables in a given database.]' \
|
||||
'sql-dump[Exports the Drupal DB as SQL using mysqldump or equivalent.]' \
|
||||
'(sql-query)'{sql-query,sqlq}'[Execute a query against the site database.]' \
|
||||
'sql-sync[Copy and import source database to target database. Transfers via rsync.]' \
|
||||
'(user-login)'{user-login,uli}'[Display a one time login link for the given user account (defaults to uid 1).]' \
|
||||
'(user-password)'{user-password,upwd}'[(Re)Set the password for the user account with the specified name.]' \
|
||||
&& ret=0
|
||||
;;
|
||||
args)
|
||||
case $line[1] in
|
||||
(user-password|upwd)
|
||||
_arguments \
|
||||
'--password=:Set the password for the username someuser.' \
|
||||
&& ret=0
|
||||
;;
|
||||
(help)
|
||||
_values 'commands' 'archive-dump' 'ard' 'arb' 'archive-restore' 'arr' 'cache-clear' 'cc' 'core-cron' 'exec' 'drupal-directory' 'dd' 'help' 'image-flush' 'site-alias' 'sa' 'site-install' 'si' 'test-clean' 'test-run' 'updatedb' 'updb' 'pm-list' 'pml' 'pm-uninstall' 'pm-update' 'pm-disable' 'dis' 'pm-download' 'pm-enable' 'en'
|
||||
;;
|
||||
(cc)
|
||||
_values 'options' 'all' 'drush' 'theme-registry' 'menu' 'css-js' 'block'
|
||||
;;
|
||||
(pm-list|pml)
|
||||
_arguments \
|
||||
'(--core)--core[Filter out extensions that are not in drupal core.]' \
|
||||
'(--no-core)--no-core[Filter out extensions that are provided by drupal core.]' \
|
||||
'(--pipe)--pipe[Returns a whitespace delimited list of the names of the resulting extensions.]' \
|
||||
'(--status)--status=-[Filter by extension status. Choices: enabled, disabled and/or "not installed".]:status:(enabled disabled)' \
|
||||
'(--type)--type=-[Filter by extensions ension type. Choices: module, theme.]:type:(module theme)' \
|
||||
&& ret=0
|
||||
;;
|
||||
(pm-disable|dis)
|
||||
_modules=( $(drush pml --status=enabled --pipe) )
|
||||
if [[ $_modules != "" ]]; then
|
||||
_values 'enabled modules' $_modules
|
||||
fi
|
||||
;;
|
||||
(pm-enable|en)
|
||||
_arguments -C \
|
||||
'--resolve-dependencies[Attempt to download any missing dependencies. At the moment, only works when the module name is the same as the project name.]' \
|
||||
'--skip[Skip automatic downloading of libraries (c.f. devel).]' && ret=0
|
||||
_modules=( $(drush pml --status="disabled,not installed" --pipe) )
|
||||
if [[ $_modules != "" ]]; then
|
||||
_values -s 'not yet enabled modules' $_modules && ret=0
|
||||
fi
|
||||
;;
|
||||
(*)
|
||||
_values 'Global options' \
|
||||
{-d,--debug}'[Display even more information, including internal messages.]' \
|
||||
{-v,--verbose}'[Display extra information about the command.]' \
|
||||
{-y,--yes}'[Assume "yes" as answer to all prompts.]' \
|
||||
{-n,--no}'[Assume "no" as answer to all prompts.]' \
|
||||
{-s,--simulate}'[Simulate all relevant actions (dont actually change the system).]' \
|
||||
{-r,--root=}'[Drupal root directory to use (default: current directory).]' \
|
||||
{-l,--uri=}'[URI of the drupal site to use (only needed in multisite environments or when running on an alternate port).]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_drush '$@'
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
Loading…
Reference in New Issue