#!/usr/bin/env ruby

HELP = "USAGE: info <url|revision|author|date>"

info = {}
`svn info`.split("\n").each {|line|
  line =~ /(\w+):(.*)/
  info[$1.downcase] = $2.strip
}

info['tag'] = info['url'].split("/")[-1]
info['date'] = info['date'].split(" ")[0,3].join(" ")

if ARGV.length < 1
  puts info.collect {|k,v| "#{k}=#{v}"}.join("\n")
  exit 0
end

k = case ARGV[0]
    when /^t/: 'tag'
    when /^u/: 'url'
    when /^r/: 'revision'
    when /^a/: 'author'
    when /^d/: 'date'
    else
      puts %Q{Unrecognized command "#{ARGV[0]}"}
      puts HELP
      exit 1
    end

puts info[k]


