d83c9f8eb97916f3d0ac7604887dbb536c98ba08
12 def check_arity(req_args
, num_args
)
13 if ((req_args
> 0 and num_args !
= req_args
) ||
14 (req_args
< 0 and num_args
< req_args
.abs
))
15 puts
"Wrong number of arguments for specified sub command"
23 puts
"Invalid node name #{node}"
26 return {:host => s
[0], :port => s
[1].to_i
}
29 def connect_to_node(naddr
)
30 xputs
"Connecting to node #{naddr[:host]}:#{naddr[:port]}: "
32 r
= Redis
.new(:host => naddr
[:host], :port => naddr
[:port])
36 puts
"Sorry, can't connect to node #{naddr[:host]}:#{naddr[:port]}"
43 puts
"Creating cluster"
44 ARGV[1..-1].each
{|node
|
45 naddr
= parse_node(node
)
46 r
= connect_to_node(naddr
)
52 "create-cluster" => ["create_cluster", -2]
57 puts
"Usage: redis-trib <command> <arguments ...>"
62 cmd_spec
= COMMANDS
[ARGV[0].downcase
]
64 puts
"Unknown redis-trib subcommand '#{ARGV[0]}'"
67 rt
.check_arity(cmd_spec
[1],ARGV.length
)