help 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/usr/bin/env bash
  2. rvm_base_except="selector"
  3. source "$rvm_scripts_path/base"
  4. source "$rvm_scripts_path/functions/version"
  5. __rvm_help_find()
  6. {
  7. \typeset _full_name
  8. \typeset -a _full_paths
  9. _full_name=""
  10. _full_paths=()
  11. _matched=""
  12. case "$1" in
  13. (*/*) return 1 ;;
  14. esac
  15. # start with shortest, build path and prepend it to beginning
  16. while (( $# > 0 ))
  17. do
  18. _full_name="${_full_name:-}${1:-}"
  19. _full_paths=( "${_full_name}.md" "${_full_paths[@]}" )
  20. _full_name="${_full_name:-}/"
  21. shift
  22. done
  23. # check longest paths first
  24. for _full_name in "${_full_paths[@]}"
  25. do
  26. if
  27. [[ -n "${_full_name}" && -s "${rvm_help_path}/${_full_name}" ]]
  28. then
  29. echo "${rvm_help_path}/${_full_name}"
  30. return 0
  31. elif
  32. [[ -n "${_full_name}" && -s "${rvm_docs_path}/${_full_name}" ]]
  33. then
  34. echo "${rvm_docs_path}/${_full_name}"
  35. return 0
  36. fi
  37. done
  38. return 1
  39. }
  40. __rvm_help()
  41. {
  42. \typeset _matched
  43. __rvm_print_headline
  44. if
  45. _matched="$(__rvm_help_find "$@")"
  46. then
  47. __rvm_pager_or_cat_v "${_matched}"
  48. else
  49. [[ -z "$1" ]] || rvm_error "Documentation for 'rvm $*' not found"
  50. __rvm_pager_or_cat_v "${rvm_path:-$HOME/.rvm}/help/index.txt"
  51. fi
  52. rvm_log "
  53. For additional documentation please visit $(__rvm_version_website)
  54. "
  55. }
  56. __rvm_help "$@"