def do_diff(argv)
opt = OptionParser.new
opt.banner = 'Usage: wfo diff [options] [local-filename...]'
opt_u = false; opt.def_option('-u', 'update check') { opt_u = true }
opt.def_option('-h', 'help') { puts opt; exit 0 }
opt.parse!(argv)
WebClient.do {
ws = argv_to_workareas(argv)
no_diff = true
ws.each {|w|
local_text = w.local_text
if opt_u
accessor = w.make_accessor
other_text = accessor.current_text
other_label = "#{w.filename} (remote)"
else
other_text = w.original_text
other_label = "#{w.filename} (original)"
end
if other_text != local_text
no_diff = false
other_file = tempfile("wfo.other", other_text)
local_file = tempfile("wfo.local", local_text)
command = ['diff', '-u',
"--label=#{other_label}", other_file.path,
"--label=#{w.filename}", local_file.path]
system(Escape.shell_command(command))
end
}
exit no_diff
}
end