make --default boolean in type __rvm_ruby

Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
Nico Schottelius 2012-11-07 19:27:17 +01:00
parent 3d4bb3837f
commit 482ec3c5d8
3 changed files with 23 additions and 22 deletions

View file

@ -24,23 +24,24 @@ user="$(cat "$__object/parameter/user")"
default="$(cat "$__object/parameter/default" 2>/dev/null || true)"
state_should="$(cat "$__object/parameter/state")"
if [ "$state_is" != "$state_should" ]; then
case "$state_should" in
present)
echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
"rvm install $ruby\""
case "$default" in
no)
;;
*)
echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
"rvm use --default $ruby\""
;;
esac
;;
absent)
echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
"rvm remove $ruby\""
;;
esac
fi
[ "$state_is" = "$state_should" ] && exit 0
case "$state_should" in
present)
echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
"rvm install $ruby\""
if [ -f "$__object/parameter/default" ]; then
echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
"rvm use --default $ruby\""
fi
;;
absent)
echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
"rvm remove $ruby\""
;;
*)
echo "Unknown state $state_should" >&2
exit 1
;;
esac

View file

@ -23,7 +23,7 @@ state::
BOOLEAN PARAMETERS
------------------
default:
If set to anything but "no" (the default), set the given version as default
Set the given version as default
EXAMPLES
--------
@ -33,7 +33,7 @@ EXAMPLES
__rvm_ruby ruby-1.9.3-p0 --user thelonious --state present
# Install ruby 1.9.3 through rvm for user ornette and make it the default
__rvm_ruby ruby-1.9.3-p0 --user ornette --state present --default yes
__rvm_ruby ruby-1.9.3-p0 --user ornette --state present --default
# Remove ruby 1.9.3 for user john
__rvm_ruby ruby-1.9.3-p0 --user john --state absent