My personal dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_drush 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. #compdef drush
  2. # ------------------------------------------------------------------------------
  3. # Copyright (c) 2014 Github zsh-users - http://github.com/zsh-users
  4. # All rights reserved.
  5. #
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions are met:
  8. # * Redistributions of source code must retain the above copyright
  9. # notice, this list of conditions and the following disclaimer.
  10. # * Redistributions in binary form must reproduce the above copyright
  11. # notice, this list of conditions and the following disclaimer in the
  12. # documentation and/or other materials provided with the distribution.
  13. # * Neither the name of the zsh-users nor the
  14. # names of its contributors may be used to endorse or promote products
  15. # derived from this software without specific prior written permission.
  16. #
  17. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  18. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. # DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
  21. # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. # ------------------------------------------------------------------------------
  28. # Description
  29. # -----------
  30. #
  31. # Completion script for Drush (http://drush.ws).
  32. #
  33. # ------------------------------------------------------------------------------
  34. # Authors
  35. # -------
  36. #
  37. # * Vasily Kraev (https://github.com/vasilykraev)
  38. #
  39. # ------------------------------------------------------------------------------
  40. _drush() {
  41. local curcontext='$curcontext' state line cmds ret=1
  42. integer NORMARG
  43. typeset -A opt_args
  44. global_args=('--debug' '--verbose' '--yes' '--no' '--simulate' '--root=' '--uri=')
  45. _arguments -C \
  46. '(--*)'{--version,--version}'[Show drush version.]' \
  47. '(- *)'{-d,--debug}'[Display even more information, including internal messages.]' \
  48. '(- *)'{-v,--verbose}'[Display extra information about the command.]' \
  49. '(- *)'{-y,--yes}'[Assume "yes" as answer to all prompts.]' \
  50. '(- *)'{-n,--no}'[Assume "no" as answer to all prompts.]' \
  51. '(- *)'{-s,--simulate}'[Simulate all relevant actions (dont actually change the system).]' \
  52. '(- *)'{-r,--root=}'[Drupal root directory to use (default: current directory).]' \
  53. '(- *)'{-l,--uri=}'[URI of the drupal site to use (only needed in multisite environments or when running on an alternate port).]' \
  54. '1: :->cmds' \
  55. '*::arg:->args' \
  56. && ret=0
  57. case $state in
  58. cmds)
  59. _values 'drush command' \
  60. '(archive-dump)'{archive-dump,ard,arb}'[Backup your code, files, and database into a single file.]' \
  61. '(archive-restore)'{archive-restore,arr}'[Expand a site archive into a Drupal web site.]' \
  62. '(cache-clear)'{cache-clear,cc}'[Clear a specific cache, or all drupal caches.]' \
  63. '(core-status)'{core-status,status,st}'[Provides a birds-eye view of the current Drupal installation, if any.]' \
  64. '(core-cron)'{core-cron,cron}'[Run all cron hooks in all active modules for specified site.]' \
  65. '(core-execute)'{core-execute,exec}'[Execute a shell command. Usually used with a site alias.]' \
  66. '(drupal-directory)'{drupal-directory,dd}'[Return the filesystem path for modules/themes and other key folders.]' \
  67. 'help[Print this help message.]' \
  68. 'image-flush[Flush all derived images for a given style.]' \
  69. '(site-alias)'{site-alias,sa}'[Print an alias record.]' \
  70. '(site-install)'{site-install,si}'[Install Drupal along with modules/themes/configuration using the specified install profile.]' \
  71. 'test-clean[Clean temporary tables and files.]' \
  72. 'test-run[Run tests. Note that you must use the --uri option.]' \
  73. '(updatedb)'{updatedb,updb}'[Apply any database updates required (as with running update.php).]' \
  74. '(variable-delete)'{variable-delete,vdel}'[Delete a variable.]' \
  75. '(variable-get)'{variable-get,vget}'[Get a list of some or all site variables and values.]' \
  76. '(variable-set)'{variable-set,vset}'[Set a variable.]' \
  77. '(pm-list)'{pm-list,pml}'[Show a list of available extensions (modules and themes).]' \
  78. '(pm-disable)'{pm-disable,dis}'[Disable one or more extensions (modules or themes). Disable dependant extensions as well.]' \
  79. '(pm-download)'{pm-download,dl}'[Download projects from drupal.org or other sources.]' \
  80. '(pm-enable)'{pm-enable,en}'[Enable one or more extensions (modules or themes). Enable dependant extensions as well.]' \
  81. 'pm-uninstall[Uninstall one or more modules.]' \
  82. 'pm-update[Update Drupal core and contrib projects and apply any pending database updates (Same as pm-updatecode + updatedb).]' \
  83. '(sql-cli)'{sql-cli,sqlc}'[Open a SQL command-line interface using Drupals credentials.]' \
  84. 'sql-drop[Drop all tables in a given database.]' \
  85. 'sql-dump[Exports the Drupal DB as SQL using mysqldump or equivalent.]' \
  86. '(sql-query)'{sql-query,sqlq}'[Execute a query against the site database.]' \
  87. 'sql-sync[Copy and import source database to target database. Transfers via rsync.]' \
  88. '(user-login)'{user-login,uli}'[Display a one time login link for the given user account (defaults to uid 1).]' \
  89. '(user-password)'{user-password,upwd}'[(Re)Set the password for the user account with the specified name.]' \
  90. '(devel-reinstall)'{devel-reinstall,dre}'[Disable, Uninstall, and Install a list of projects. (devel)]' \
  91. '(devel-token)'{devel-token,token}'[List available tokens (devel)]' \
  92. '(generate-content)'{generate-content,genc}'[Create content. (devel_generate)]' \
  93. '(generate-menus)'{generate-menus,genm}'[Create menus and menu items. (devel_generate)]' \
  94. '(generate-terms)'{generate-terms,gent}'[Create terms in specified vocabulary. (devel_generate)]' \
  95. '(generate-users)'{generate-users,genu}'[Create users. (devel_generate)]' \
  96. '(generate-vocabs)'{generate-vocabs,genv}'[Create vocabularies. (devel_generate)]' \
  97. '(features-diff)'{features-diff,fd}'[Show the difference between the default and overridden state of a feature.]' \
  98. '(features-export)'{features-export,fe}'[Export a feature from your site into a module.]' \
  99. '(features-list)'{features-list,fl}'[List all the available features for your site.]' \
  100. '(features-revert)'{features-revert,fr}'[Revert a feature module on your site.]' \
  101. '(features-revert-all)'{features-revert-all,fra}'[Revert all enabled feature module on your site.]' \
  102. '(features-update)'{features-update,fu}'[Update a feature module on your site.]' \
  103. '(features-update-all)'{features-update-all,fua}'[Update all feature modules on your site.]' \
  104. && ret=0
  105. ;;
  106. args)
  107. case $line[1] in
  108. (archive-dump|ard)
  109. _arguments \
  110. '(--description)--description=[Filter out extensions that are provided by drupal core.]' \
  111. '(--destination)--destination=[The full path and filename in which the archive should be stored. If omitted, it will be saved to the drush-backups directory.]' \
  112. '(--no-core)--no-core[Exclude Drupal core, so the backup only contains the site specific stuff.]' \
  113. '(--pipe)--pipe[Only print the destination of the archive. Useful for scripts that dont pass --destination.]' \
  114. '(--tar-options)--tar-options=[Options passed thru to the tar command.]' \
  115. && ret=0
  116. compadd -a global_args
  117. ;;
  118. (archive-restore|arr)
  119. _arguments \
  120. '(--db-prefix)--db-prefix[An optional table prefix to use during restore.]' \
  121. '(--db-su)--db-su[Account to use when creating the new database. Optional.]' \
  122. '(--db-su-pw)--db-su-pw[Password for the "db-su" account. Optional.]' \
  123. '(--db-url)--db-url=[A Drupal 6 style database URL indicating the target for database restore. If not provided, the archived settings.php is used. ]' \
  124. '(--destination)--destination[Specify where the Drupal site should be expanded, including the docroot. Defaults to the current working directory.]' \
  125. '(--overwrite)--overwrite[Allow drush to overwrite any files in the destination.]' \
  126. && ret=0
  127. compadd -a global_args
  128. ;;
  129. (user-password|upwd)
  130. _arguments \
  131. '--password=:Set the password for the username someuser.' \
  132. && ret=0
  133. ;;
  134. (help)
  135. _values 'commands' 'arb' 'archive-dump' 'archive-restore' 'ard' 'arr' 'cache-clear' 'cc' 'core-cron' 'core-execute' 'core-status' 'cron' 'dd' 'devel-reinstall' 'devel-token' 'dis' 'dl' 'dre' 'drupal-directory' 'en' 'exec' 'fd' 'fe' 'features-diff' 'features-export' 'features-list' 'features-revert' 'features-revert-all' 'features-update' 'features-update-all' 'fl' 'fr' 'fra' 'fu' 'fua' 'genc' 'generate-content' 'generate-menus' 'generate-terms' 'generate-users' 'generate-vocabs' 'genm' 'gent' 'genu' 'genv' 'help' 'image-flush' 'pm-disable' 'pm-download' 'pm-enable' 'pm-list' 'pm-uninstall' 'pm-update' 'pml' 'sa' 'si' 'site-alias' 'site-install' 'sql-cli' 'sql-drop' 'sql-dump' 'sql-query' 'sql-sync' 'sqlc' 'sqlq' 'st' 'status' 'test-clean' 'test-run' 'token' 'uli' 'updatedb' 'updb' 'upwd' 'user-login' 'user-password' 'variable-delete' 'variable-get' 'variable-set' 'vdel' 'vget' 'vset'
  136. ;;
  137. (cc)
  138. _values 'options' 'all' 'drush' 'theme-registry' 'menu' 'css-js' 'block'
  139. ;;
  140. (pm-list|pml)
  141. _arguments \
  142. '(--core)--core[Filter out extensions that are not in drupal core.]' \
  143. '(--no-core)--no-core[Filter out extensions that are provided by drupal core.]' \
  144. '(--pipe)--pipe[Returns a whitespace delimited list of the names of the resulting extensions.]' \
  145. '(--status)--status=-[Filter by extension status. Choices: enabled, disabled and/or "not installed".]:status:(enabled disabled)' \
  146. '(--type)--type=-[Filter by extensions ension type. Choices: module, theme.]:type:(module theme)' \
  147. && ret=0
  148. ;;
  149. (pm-disable|dis)
  150. _modules=( $(drush pml --status=enabled --pipe) )
  151. if [[ $_modules != "" ]]; then
  152. _values 'enabled modules' $_modules
  153. fi
  154. ;;
  155. (pm-enable|en)
  156. _arguments -C \
  157. '--resolve-dependencies[Attempt to download any missing dependencies. At the moment, only works when the module name is the same as the project name.]' \
  158. '--skip[Skip automatic downloading of libraries (c.f. devel).]' && ret=0
  159. _modules=( $(drush pml --status="disabled,not installed" --pipe) )
  160. if [[ $_modules != "" ]]; then
  161. _values -s 'not yet enabled modules' $_modules && ret=0
  162. fi
  163. ;;
  164. (*)
  165. _values 'Global options' \
  166. {-d,--debug}'[Display even more information, including internal messages.]' \
  167. {-v,--verbose}'[Display extra information about the command.]' \
  168. {-y,--yes}'[Assume "yes" as answer to all prompts.]' \
  169. {-n,--no}'[Assume "no" as answer to all prompts.]' \
  170. {-s,--simulate}'[Simulate all relevant actions (dont actually change the system).]' \
  171. {-r,--root=}'[Drupal root directory to use (default: current directory).]' \
  172. {-l,--uri=}'[URI of the drupal site to use (only needed in multisite environments or when running on an alternate port).]'
  173. ;;
  174. esac
  175. ;;
  176. esac
  177. }
  178. _drush '$@'
  179. # Local Variables:
  180. # mode: Shell-Script
  181. # sh-indentation: 2
  182. # indent-tabs-mode: nil
  183. # sh-basic-offset: 2
  184. # End:
  185. # vim: ft=zsh sw=2 ts=2 et