_gem 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #compdef gem
  2. #autoload
  3. # gem zsh completion, based on homebrew completion
  4. _gem_installed() {
  5. installed_gems=(`gem list --local --no-versions`)
  6. }
  7. local -a _1st_arguments
  8. _1st_arguments=(
  9. 'cert:Manage RubyGems certificates and signing settings'
  10. 'check:Check installed gems'
  11. 'cleanup:Clean up old versions of installed gems in the local repository'
  12. 'contents:Display the contents of the installed gems'
  13. 'dependency:Show the dependencies of an installed gem'
  14. 'environment:Display information about the RubyGems environment'
  15. 'fetch:Download a gem and place it in the current directory'
  16. 'generate_index:Generates the index files for a gem server directory'
  17. 'help:Provide help on the `gem` command'
  18. 'install:Install a gem into the local repository'
  19. 'list:Display gems whose name starts with STRING'
  20. 'lock:Generate a lockdown list of gems'
  21. 'mirror:Mirror a gem repository'
  22. 'outdated:Display all gems that need updates'
  23. 'owner:Manage gem owners on RubyGems.org.'
  24. 'pristine:Restores installed gems to pristine condition from files located in the gem cache'
  25. 'push:Push a gem up to RubyGems.org'
  26. 'query:Query gem information in local or remote repositories'
  27. 'rdoc:Generates RDoc for pre-installed gems'
  28. 'search:Display all gems whose name contains STRING'
  29. 'server:Documentation and gem repository HTTP server'
  30. 'sources:Manage the sources and cache file RubyGems uses to search for gems'
  31. 'specification:Display gem specification (in yaml)'
  32. 'stale:List gems along with access times'
  33. 'uninstall:Uninstall gems from the local repository'
  34. 'unpack:Unpack an installed gem to the current directory'
  35. 'update:Update the named gems (or all installed gems) in the local repository'
  36. 'which:Find the location of a library file you can require'
  37. )
  38. local expl
  39. local -a gems installed_gems
  40. _arguments \
  41. '(-v --version)'{-v,--version}'[show version]' \
  42. '(-h --help)'{-h,--help}'[show help]' \
  43. '*:: :->subcmds' && return 0
  44. if (( CURRENT == 1 )); then
  45. _describe -t commands "gem subcommand" _1st_arguments
  46. return
  47. fi
  48. case "$words[1]" in
  49. list)
  50. if [[ "$state" == forms ]]; then
  51. _gem_installed
  52. _requested installed_gems expl 'installed gems' compadd -a installed_gems
  53. fi ;;
  54. uninstall|update)
  55. _gem_installed
  56. _wanted installed_gems expl 'installed gems' compadd -a installed_gems ;;
  57. esac