2011-08-12 05:33:45 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
2011-08-10 09:53:24 -04:00
|
|
|
|
|
|
|
print_set_version() {
|
2011-08-10 10:23:43 -04:00
|
|
|
echo "<version> should be a string matching a Ruby version known by rbenv."
|
|
|
|
|
|
|
|
local versions="$(rbenv-versions --bare)"
|
|
|
|
if [ -z "$versions" ]; then
|
|
|
|
echo "There are currently no Ruby versions installed for rbenv."
|
|
|
|
else
|
|
|
|
echo "The currently installed Ruby versions are:"
|
|
|
|
echo "$versions" | sed 's/^/ /'
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "The special version string 'system' will use your default system Ruby."
|
2011-08-10 09:53:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
"") echo "usage: rbenv <command> [<args>]
|
|
|
|
|
|
|
|
Some useful rbenv commands are:
|
|
|
|
commands List all commands
|
2011-08-10 10:23:43 -04:00
|
|
|
rehash Rehash rbenv shims (run this after installing binaries)
|
|
|
|
set-default Set the default Ruby version
|
|
|
|
set-local Set a local directory-specific Ruby version
|
|
|
|
version Show the current Ruby version
|
|
|
|
versions List all Ruby versions known by rbenv
|
2011-08-10 09:53:24 -04:00
|
|
|
|
|
|
|
See 'rbenv help <command>' for more information on a specific command.
|
2011-08-11 17:43:57 -04:00
|
|
|
For more information, see: https://github.com/sstephenson/rbenv#readme"
|
2011-08-10 09:53:24 -04:00
|
|
|
;;
|
|
|
|
set-default) echo "usage: rbenv set-default <version>
|
|
|
|
|
2011-08-10 10:23:43 -04:00
|
|
|
Sets the default Ruby version. You can override the default at any time
|
2011-08-10 10:31:53 -04:00
|
|
|
by setting a directory-specific version with \`rbenv set-local' or by
|
2011-08-10 10:23:43 -04:00
|
|
|
setting the RBENV_VERSION environment variable.
|
2011-08-10 09:53:24 -04:00
|
|
|
|
|
|
|
$(print_set_version)"
|
|
|
|
;;
|
|
|
|
set-local) echo "usage: rbenv set-local <version>
|
|
|
|
|
2011-08-10 10:23:43 -04:00
|
|
|
Sets the local directory-specific Ruby version by writing the version
|
|
|
|
name to a file named '.rbenv-version'.
|
|
|
|
|
|
|
|
When you run a Ruby command, rbenv will look for an '.rbenv-version'
|
|
|
|
file in the current directory and each parent directory. If no such
|
|
|
|
file is found in the tree, rbenv will use the default Ruby version
|
|
|
|
specified with \`rbenv set-default', or the version specified in the
|
|
|
|
RBENV_VERSION environment variable.
|
2011-08-10 09:53:24 -04:00
|
|
|
|
|
|
|
$(print_set_version)"
|
|
|
|
;;
|
|
|
|
*) echo "No command arguments needed or invalid/undocumented command."
|
|
|
|
esac
|