Repository: nvm-sh/nvm
File: nvm.sh (Shell)

Code before:
nvm() {
  if [ $# -lt 1 ]; then
    nvm --help
    return
  fi

  local DEFAULT_IFS
  DEFAULT_IFS=" $(nvm_echo t | command tr t \\t)
"
  if [ "${-#*e}" != "$-" ]; then
    set +e
    local EXIT_CODE
    IFS="${DEFAULT_IFS}" nvm "$@"
    EXIT_CODE=$?
    set -e
    return $EXIT_CODE
  elif [ "${IFS}" != "${DEFAULT_IFS}" ]; then
    IFS="${DEFAULT_IFS}" nvm "$@"
    return $?
  fi

  argsList=("$@")
  for i in ${argsList[@]}
  do
    case $i in
      'help'|'-help'|'--help')
      local NVM_IOJS_PREFIX
      NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
      local NVM_NODE_PREFIX
      NVM_NODE_PREFIX="$(nvm_node_prefix)"
      NVM_VERSION="$(nvm --version)"
      nvm_echo
      nvm_echo "Node Version Manager (v${NVM_VERSION})"
      nvm_echo
      nvm_echo 'Note: <version> refers to any version-like string nvm understands. This includes:'
      nvm_echo '  - full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1)'
      nvm_echo "  - default (built-in) aliases: ${NVM_NODE_PREFIX}, stable, unstable, ${NVM_IOJS_PREFIX}, system"
      nvm_echo '  - custom aliases you define with `nvm alias foo`'
      nvm_echo
      nvm_echo ' Any options that produce colorized output should respect the `--no-colors` option.'
      nvm_echo
      nvm_echo 'Usage:'
      nvm_echo '  nvm --help                                  Show this message'
      nvm_echo '  nvm --version                               Print out the installed version of nvm'
      nvm_echo '  nvm install [-s] [<version>]                Download and install a <version>, [-s] from source. Uses .nvmrc if available'
      nvm_echo '    --reinstall-packages-from=<version>       When installing, reinstall packages installed in <node|iojs|node version number>'
      nvm_echo '    --lts                                     When installing, only select from LTS (long-term support) versions'
      nvm_echo '    --lts=<LTS name>                          When installing, only select from versions for a specific LTS line'
      nvm_echo '    --skip-default-packages                   When installing, skip the default-packages file if it exists'
      nvm_echo '    --latest-npm                              After installing, attempt to upgrade to the latest working npm on the given node version'
      nvm_echo '    --no-progress                             Disable the progress bar on any downloads'

Review comment (suggestion):
I'm a bit surprised to see `nvm -help` as an alias for `nvm --help` (i'd totally forgotten about `nvm help`). Why the extra alias? (typically, single-dash arguments are always only one letter; only double-dash arguments are longer words)

Code after:
nvm() {
  if [ $# -lt 1 ]; then
    nvm --help
    return
  fi

  local DEFAULT_IFS
  DEFAULT_IFS=" $(nvm_echo t | command tr t \\t)
"
  if [ "${-#*e}" != "$-" ]; then
    set +e
    local EXIT_CODE
    IFS="${DEFAULT_IFS}" nvm "$@"
    EXIT_CODE=$?
    set -e
    return $EXIT_CODE
  elif [ "${IFS}" != "${DEFAULT_IFS}" ]; then
    IFS="${DEFAULT_IFS}" nvm "$@"
    return $?
  fi

  for i in "$@"
  do
    case $i in
      '-h'|'help'|'--help')
        local NVM_IOJS_PREFIX
        NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
        local NVM_NODE_PREFIX
        NVM_NODE_PREFIX="$(nvm_node_prefix)"
        NVM_VERSION="$(nvm --version)"
        nvm_echo
        nvm_echo "Node Version Manager (v${NVM_VERSION})"
        nvm_echo
        nvm_echo 'Note: <version> refers to any version-like string nvm understands. This includes:'
        nvm_echo '  - full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1)'
        nvm_echo "  - default (built-in) aliases: ${NVM_NODE_PREFIX}, stable, unstable, ${NVM_IOJS_PREFIX}, system"
        nvm_echo '  - custom aliases you define with `nvm alias foo`'
        nvm_echo
        nvm_echo ' Any options that produce colorized output should respect the `--no-colors` option.'
        nvm_echo
        nvm_echo 'Usage:'
        nvm_echo '  nvm --help                                  Show this message'
        nvm_echo '  nvm --version                               Print out the installed version of nvm'
        nvm_echo '  nvm install [-s] [<version>]                Download and install a <version>, [-s] from source. Uses .nvmrc if available'
        nvm_echo '    --reinstall-packages-from=<version>       When installing, reinstall packages installed in <node|iojs|node version number>'
        nvm_echo '    --lts                                     When installing, only select from LTS (long-term support) versions'
        nvm_echo '    --lts=<LTS name>                          When installing, only select from versions for a specific LTS line'
        nvm_echo '    --skip-default-packages                   When installing, skip the default-packages file if it exists'
        nvm_echo '    --latest-npm                              After installing, attempt to upgrade to the latest working npm on the given node version'
        nvm_echo '    --no-progress                             Disable the progress bar on any downloads'
        nvm_echo '    --alias=<name>                            After installing, set the alias specified to the version specified. (same as: nvm alias <name> <version>)'