def do_checkout(argv)
opt = OptionParser.new
opt.banner = 'Usage: wfo checkout [-t repo_type] URL [local-filename][.ext]'
opt_t = nil; opt.def_option('-t repo_type', "repository type (#{Repo.available_types})") {|v|
opt_t = v
}
opt.def_option('-h', 'help') { puts opt; exit 0 }
opt.parse!(argv)
WebClient.do {
url = URI(argv.shift)
local_filename_arg = argv.shift
if !local_filename_arg
extname = '.txt'
elsif /^\./ =~ local_filename_arg
extname = local_filename_arg
else
if /\./ =~ local_filename_arg
local_filename = local_filename_arg
else
local_filename = local_filename_arg + '.txt'
end
if WorkArea.has?(local_filename)
err "local file already exists : #{local_filename.inspect}"
end
end
repo_class, stable_uri = Repo.find_class_and_stable_uri(url, opt_t)
accessor = repo_class.make_accessor(stable_uri)
if !local_filename
local_filename = make_local_filename(accessor.recommended_filename, extname)
end
workarea = WorkArea.new(local_filename, accessor.class.type, stable_uri, accessor.form, accessor.textarea_name)
workarea.store
puts local_filename
}
end