Skip to content

Commit

Permalink
Feature: Added 'rvm list known_strings', thanks to lenary for the idea.
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneeseguin committed Jul 7, 2010
1 parent 5248693 commit 9a63b7b
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions scripts/list
Expand Up @@ -2,12 +2,6 @@

if [[ "$rvm_trace_flag" -eq 2 ]] ; then set -x ; export rvm_trace_flag ; fi

# Query for valid rvm ruby strings
# This is meant to be used with scripting.
list_strings() {
echo $(\ls $rvm_rubies_path)
}

list_gemsets() {
echo
ruby=$(command -v ruby) ; current_ruby=""
Expand Down Expand Up @@ -74,6 +68,17 @@ list_ruby_svn_tags() {
done < <(svn list http://svn.ruby-lang.org/repos/ruby/tags/ | awk '/^v1_[8|9]/')
}

# Query for valid rvm ruby strings
# This is meant to be used with scripting.
list_strings() {
echo $(\ls $rvm_rubies_path)
}

# This is meant to be used with scripting.
list_known_strings() {
cat "$rvm_config_path/known" | sed -e 's/#.*$//g' -e 's/(//g' -e 's/)//g' | sort -r | uniq
}

list_known() {
if [[ -z "$rvm_interactive" ]] || [[ -z "$TERM" ]] || [[ "unknown" = "$TERM" ]] ; then
cat "$rvm_config_path/known"
Expand All @@ -82,6 +87,7 @@ list_known() {
fi
}


list_rubies() {
echo
ruby=$(command -v ruby) ; current_ruby=""
Expand Down Expand Up @@ -128,6 +134,8 @@ action="$(echo "$1" | awk '{print $1}')"

if [[ "known" = "$action" ]] ; then
list_known
elif [[ "known_strings" = "$action" ]] ; then
list_known_strings
elif [[ "gemsets" = "$action" ]] ; then
list_gemsets
elif [[ "default" = "$action" ]] ; then
Expand All @@ -139,7 +147,7 @@ elif [[ "strings" = "$action" ]] ; then
elif [[ "ruby_svn_tags" = "$action" ]] ; then
list_ruby_svn_tags
else # help
printf "\nUsage: rvm list {known,gemsets,default,rubies,strings}"
printf "\nUsage: rvm list {known,gemsets,default,rubies,strings,known_strings}"
fi

exit $?

2 comments on commit 9a63b7b

@lenary
Copy link

@lenary lenary commented on 9a63b7b Jul 7, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! that was quick!

@Sutto
Copy link
Contributor

@Sutto Sutto commented on 9a63b7b Jul 8, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yah! this means I can remove the implementation I used in the ruby api. Also,
the ruby version has another option that expands the variables (so, it lists possible
strings not just the base) - I'll have to see if I can get that working with sed.

Please sign in to comment.