Skip to content

Instantly share code, notes, and snippets.

@repomaa
Created May 10, 2013 01:27
Show Gist options
  • Save repomaa/5551828 to your computer and use it in GitHub Desktop.
Save repomaa/5551828 to your computer and use it in GitHub Desktop.
begin
method = UI.ask_with_options(method_options, "l", "b", "s")
source = UI.ask("Copy from: ")
destination = UI.ask("Copy to: ")
case method
when "l"
CopyCtrl.copy_by_line source, destination
when "b"
begin
blocksize = UI.ask("Set blocksize (4096)", "Invalid blocksize.") do |input|
input.empty? || input.to_i.to_s == input && input.to_i > 0
end
rescue EOFError
blocksize = 4096
end
CopyCtrl.copy_by_block source, destination, blocksize.to_i
when "s"
CopyCtrl.copy_by_system source, destination
end
rescue CopyCtrl::OverwriteError
retry
rescue Errno::EACCES,Errno::ENOENT => e
puts e.message
retry
rescue Interrupt
#Ctrl-C, Ctrl-D or Enter
exit 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment