Thursday, April 14, 2005

CVS update script

getting sick of verbose output. I once again realized why I love Ruby:
-----Begin code, cvsupdate.rb-----

#!/usr/bin/ruby
puts "Now updating imsteam...."
result=`cvs update -dP 2>&1`.split(/\n/)
colormodified="\e[0;36m"
colormerged="\e[0;34m"
colornon="\e[0;32m"
colorconflict="\e[0;31m"
colorupdated="\e[0;35m"
colorremoved="\e[0;34m"
endcolor="\e[0m"

puts "//-------------------//"
puts " Results "
puts "//-------------------//"
for element in result
#!/usr/bin/ruby
puts "Now updating imsteam...."
result=`cvs update -dP 2>&1`.split(/\n/)
colormodified="\e[36m"
colornon="\e[32m"
colorconflict="\e[31m"
colormerged="\e[34m"
colorupdated="\e[35m"
colorremoved="\e[34m"
endcolor="\e[m"

puts "//-------------------//"
puts " Results "
puts "//-------------------//"
for element in result
character=element[0,2]
filename=element[2,element.size]
state=""
case character
when "M ":
state="#{colormodified}MODIFIED: #{endcolor}"
when "C ":
state="#{colorconflict}CONFLICT: #{endcolor}"
when "P ":
state="#{colormerged}MERGED: #{endcolor}"
when "U ":
state= "#{colorupdated}UPDATED: #{endcolor}"
when "R ":
state= "#{colorremoved}REMOVED: #{endcolor}"
when "? ":
state= "#{colornon}(NONCVS) #{endcolor}"
end
if (state!="") then
puts "#{state} #{filename}"
end
end

-----End code-----

No comments: