lib/redis-copy/cli.rb in redis-copy-0.0.5 vs lib/redis-copy/cli.rb in redis-copy-0.0.6
- old
+ new
@@ -3,14 +3,14 @@
require 'redis-copy'
require 'optparse'
module RedisCopy
class CLI
- REDIS_URI = (/\A(?:redis:\/\/)?([a-z0-9\-.]+)(:[0-9]{1,5})?(\/(?:(?:1[0-5])|[0-9]))?\z/i).freeze
+ REDIS_URI = (/\A(?:redis:\/\/)?(\w*:\w+@)?([a-z0-9\-.]+)(:[0-9]{1,5})?(\/(?:(?:1[0-5])|[0-9]))?\z/i).freeze
DEFAULTS = {
ui: :command_line,
- key_emitter: :default,
+ key_emitter: :auto,
strategy: :auto,
verify: 0,
pipeline: :true,
fail_fast: false,
prompt: true,
@@ -23,19 +23,19 @@
argv = argv.dup
options = {}
OptionParser.new do |opts|
opts.version = RedisCopy::VERSION
- opts.banner = "#{opts.program_name} v#{opts.version}\n" +
+ opts.banner = "#{opts.program_name} v#{opts.version} (with redis-rb #{Redis::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
opts.separator " <source> and <destination> must be redis connection uris"
- opts.separator " like [redis://]<hostname>[:<port>][/<db>]"
+ opts.separator " like [redis://][<username>:<password>@]<hostname>[:<port>][/<db>]"
opts.separator ''
opts.separator "Specific options:"
opts.on('--strategy STRATEGY', [:auto, :new, :classic],
indent_desc.(
@@ -44,9 +44,20 @@
" new: use redis DUMP and RESTORE commands (faster)\n" +
" classic: migrates via multiple type-specific commands"
)
) do |strategy|
options[:strategy] = strategy
+ end
+
+ opts.on('--emitter EMITTER', [:auto, :scan, :keys],
+ indent_desc.(
+ "Select key emitter (auto, keys, scan) (default #{DEFAULTS[:strategy]})\n" +
+ " auto: uses scan if available, otherwise fallback\n" +
+ " scan: use redis SCAN command (faster, less blocking)\n" +
+ " keys: uses redis KEYS command (dangerous, esp. on large datasets)"
+ )
+ ) do |emitter|
+ options[:key_emitter] = emitter
end
opts.on('--[no-]pipeline',
"Use redis pipeline where available (default #{DEFAULTS[:pipeline]})"
) do |pipeline|