bin/fingerpoken.rb in fingerpoken-0.2.20110104190832 vs bin/fingerpoken.rb in fingerpoken-0.3.0

- old
+ new

@@ -26,10 +26,12 @@ end # GET /style.css end def main(args) targets = [] + passphrase = nil + opts = OptionParser.new do |opts| opts.banner = "Usage: #{$0} [options]" opts.on("-t TARGET", "--target TARGET", "Target a url. Can be given multiple times to target multiple things.") do |url| @@ -47,10 +49,14 @@ when "tivo" require "fingerpoken/#{target.scheme}" targets << [:Tivo, { :host => target.host }] end end + + opts.on("--passphrase PASSPHRASE", "Passphrase for verifying client calls") do |val| + passphrase = val + end end opts.parse(args) if targets.size == 0 $stderr.puts "No targets given. You should specify one with -t." @@ -60,12 +66,13 @@ EventMachine::run do $:.unshift(File.dirname(__FILE__) + "/lib") channel = EventMachine::Channel.new targets.each do |klass, args| - args.merge!({ :channel => channel }) + args.merge!({ :channel => channel, :passphrase => passphrase }) target = FingerPoken::Target.const_get(klass).new(args) + target.register end # targets.each EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 5001) do |ws| ws.onmessage do |message| @@ -82,6 +89,6 @@ Rack::ShowExceptions.new( \ FingerPoken.new)), :Port => 5000) end # EventMachine::run end -exit(main(ARGV)) +main(ARGV)