lib/redis-copy/cli.rb in redis-copy-0.0.1 vs lib/redis-copy/cli.rb in redis-copy-0.0.2
- old
+ new
@@ -5,24 +5,26 @@
module RedisCopy
class CLI
REDIS_URI = (/\A(?:redis:\/\/)?([a-z0-9\-.]+)(:[0-9]{1,5})?(\/(?:(?:1[0-5])|[0-9]))?\z/i).freeze
DEFAULTS = {
- ui: :command_line,
- key_emitter: :default,
- strategy: :auto,
- fail_fast: false,
- yes: false,
+ ui: :command_line,
+ key_emitter: :default,
+ strategy: :auto,
+ fail_fast: false,
+ yes: false,
+ allow_nonempty: false,
}.freeze unless defined?(DEFAULTS)
def initialize(argv = ARGV)
argv = argv.dup
options = {}
OptionParser.new do |opts|
- opts.banner = "Usage: #{opts.program_name} [options] <source> <destination>"
opts.version = RedisCopy::VERSION
+ opts.banner = "#{opts.program_name} v#{opts.version}\n" +
+ "Usage: #{opts.program_name} [options] <source> <destination>"
indent_desc = proc do |desc|
desc.split("\n").join("\n#{opts.summary_indent}#{' '*opts.summary_width} ")
end
@@ -58,9 +60,13 @@
options[:fail_fast] = ff
end
opts.on('-y', '--yes', 'Automatically accept any prompts') do
options[:yes] = true
+ end
+
+ opts.on('--[no-]allow-nonempty', 'Allow non-empty destination') do |allow_nonempty|
+ options[:allow_nonempty] = allow_nonempty
end
opts.parse!(argv)
unless argv.size == 2
opts.abort "Source and Destination must be specified\n\n" +