8 opt = OptionParser.new do |o|
9 o.on('-t', '--timestamp[=PATH]') {|v| timestamp = v || true}
10 o.on('-o', '--output=PATH') {|v| output = v}
11 o.on('-c', '--[no-]if-change') {|v| ifchange = v}
13 end or abort opt.opt_s
15 erb = ERB.new(File.read(template), nil, '%')
16 erb.filename = template
19 if ifchange and (IO.read(output) rescue nil) == result
20 puts "#{output} unchanged"
22 open(output, "wb") {|f| f.print result}
23 puts "#{output} updated"
27 dir, base = File.split(output)
28 timestamp = File.join(dir, ".time." + base)
30 FileUtils.touch(timestamp)