bin/react in react-0.0.2 vs bin/react in react-0.1.0
- old
+ new
@@ -1,35 +1,12 @@
#!/usr/bin/env ruby
-require 'rubygems'
-require 'react'
-require 'optparse'
-require 'daemons'
-
-if ARGV.empty?
- ARGV << '--help'
-else
- if File.exists?(ARGV[0])
- options[:commands] = YAML.load_file(ARGV[0])
- else
- puts "ERROR: File not found: `#{ARGV[0]}`"
- exit
- end
+begin
+ require 'react'
+rescue LoadError
+ require 'rubygems'
+ require 'react'
end
-options = {
- :redis => {:host => '127.0.0.1', :port => 6379, :db => 0},
- :commands => {},
- :queue => 'queue'
-}
+require 'react/cli'
-opts = OptionParser.new do |opts|
- opts.banner = "Usage: react commands.yml [options]"
- opts.on('-q', '--queue [QUEUE]', 'Specify queue which will be consumed') {|val| val and options[:queue] = val }
- opts.on('-h', '--host [HOST]', 'Select redis host') {|val| val and options[:redis][:host] = val }
- opts.on('-p', '--port [PORT]', Integer, 'Select redis port') {|val| val and options[:redis][:port] = val }
- opts.on('-D', '--db [DATABASE]', 'Select redis database number') {|val| val and options[:redis][:db] = val }
- opts.on('-P', '--password [PASSWORD]', 'Select redis database password') {|val| val and options[:redis][:password] = val }
- opts.on('-d', '--daemon', 'Run in background') { options[:daemon] = true }
-end.parse(ARGV)
-
-React.start(options).join
+React::CLI.dispatch(ARGV)