| Line | |
|---|
| 1 | #!/usr/bin/env ruby |
|---|
| 2 | |
|---|
| 3 | HELP = "USAGE: info <url|revision|author|date>" |
|---|
| 4 | |
|---|
| 5 | info = {} |
|---|
| 6 | `svn info`.split("\n").each {|line| |
|---|
| 7 | line =~ /(\w+):(.*)/ |
|---|
| 8 | info[$1.downcase] = $2.strip |
|---|
| 9 | } |
|---|
| 10 | |
|---|
| 11 | info['tag'] = info['url'].split("/")[-1] |
|---|
| 12 | info['date'] = info['date'].split(" ")[0,3].join(" ") |
|---|
| 13 | |
|---|
| 14 | if ARGV.length < 1 |
|---|
| 15 | puts info.collect {|k,v| "#{k}=#{v}"}.join("\n") |
|---|
| 16 | exit 0 |
|---|
| 17 | end |
|---|
| 18 | |
|---|
| 19 | k = case ARGV[0] |
|---|
| 20 | when /^t/ then 'tag' |
|---|
| 21 | when /^u/ then 'url' |
|---|
| 22 | when /^r/ then 'revision' |
|---|
| 23 | when /^a/ then 'author' |
|---|
| 24 | when /^d/ then 'date' |
|---|
| 25 | else |
|---|
| 26 | puts %Q{Unrecognized command "#{ARGV[0]}"} |
|---|
| 27 | puts HELP |
|---|
| 28 | exit 1 |
|---|
| 29 | end |
|---|
| 30 | |
|---|
| 31 | puts info[k] |
|---|
| 32 | |
|---|
| 33 | |
|---|