您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

99 行
3.0 KiB

  1. #!/usr/bin/env bash
  2. set -e
  3. [ -n "$RBENV_DEBUG" ] && set -x
  4. print_set_version() {
  5. echo "<version> should be a string matching a Ruby version known by rbenv."
  6. local versions="$(rbenv-versions --bare)"
  7. if [ -z "$versions" ]; then
  8. echo "There are currently no Ruby versions installed for rbenv."
  9. else
  10. echo "The currently installed Ruby versions are:"
  11. echo "$versions" | sed 's/^/ /'
  12. fi
  13. echo
  14. echo "The special version string 'system' will use your default system Ruby."
  15. }
  16. case "$1" in
  17. "") echo "usage: rbenv <command> [<args>]
  18. Some useful rbenv commands are:
  19. commands List all rbenv commands
  20. rehash Rehash rbenv shims (run this after installing binaries)
  21. global Set or show the global Ruby version
  22. local Set or show the local directory-specific Ruby version
  23. shell Set or show the shell-specific Ruby version
  24. version Show the current Ruby version
  25. versions List all Ruby versions known by rbenv
  26. which Show the full path for the given Ruby command
  27. whence List all Ruby versions with the given command
  28. See 'rbenv help <command>' for information on a specific command.
  29. For full documentation, see: https://github.com/sstephenson/rbenv#readme"
  30. ;;
  31. commands) echo "usage: rbenv commands
  32. rbenv commands --sh
  33. rbenv commands --no-sh
  34. List all rbenv commands."
  35. ;;
  36. global) echo "usage: rbenv global <version>
  37. Sets the global Ruby version. You can override the global version at
  38. any time by setting a directory-specific version with \`rbenv local'
  39. or by setting the RBENV_VERSION environment variable.
  40. $(print_set_version)"
  41. ;;
  42. local) echo "usage: rbenv local <version>
  43. rbenv local --unset
  44. Sets the local directory-specific Ruby version by writing the version
  45. name to a file named '.rbenv-version'.
  46. When you run a Ruby command, rbenv will look for an '.rbenv-version'
  47. file in the current directory and each parent directory. If no such
  48. file is found in the tree, rbenv will use the global Ruby version
  49. specified with \`rbenv global', or the version specified in the
  50. RBENV_VERSION environment variable.
  51. $(print_set_version)"
  52. ;;
  53. shell) echo "usage: rbenv shell <version>
  54. rbenv shell --unset
  55. Sets a shell-specific Ruby version by setting the 'RBENV_VERSION'
  56. environment variable in your shell. This version overrides both
  57. project-specific versions and the global version.
  58. $(print_set_version)"
  59. ;;
  60. versions) echo "usage: rbenv versions
  61. rbenv versions --bare
  62. Lists all Ruby versions known by rbenv."
  63. ;;
  64. which) echo "usage: rbenv which <command>
  65. Displays the full path to the binary that rbenv will execute when you
  66. run the given command."
  67. ;;
  68. whence) echo "usage: rbenv whence <command>
  69. Lists all Ruby versions with the given command installed."
  70. ;;
  71. *)
  72. command_path="$(command -v "rbenv-$1" || true)"
  73. if [ -n "$command_path" ]; then
  74. echo "Sorry, the \`$1' command isn't documented yet."
  75. echo
  76. echo "You can view the command's source here:"
  77. echo "$command_path"
  78. echo
  79. else
  80. echo "rbenv: no such command \`$1'"
  81. fi
  82. esac