bin/fingerpoken.rb in fingerpoken-0.2.20101209171641 vs bin/fingerpoken.rb in fingerpoken-0.2.20101216024109
- old
+ new
@@ -24,22 +24,41 @@
body sass :style
end # GET /style.css
end
def main(args)
+ targets = []
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|
+ target = URI.parse(url)
+ case target.scheme
+ when "xdo"
+ require "fingerpoken/#{target.scheme}"
+ targets << [:Xdo, {}]
+ when "vnc"
+ require "fingerpoken/#{target.scheme}"
+ targets << [:VNC, {}]
+ when "tivo"
+ require "fingerpoken/#{target.scheme}"
+ targets << [:Tivo, { :host => "192.168.0.134" }]
+ end
+ end
end
+ opts.parse(args)
+
+ puts targets
+
EventMachine::run do
$:.unshift(File.dirname(__FILE__) + "/lib")
channel = EventMachine::Channel.new
- # TODO(sissel): Pick up here and make command flags to choose the
- # target (vnc, xdo, etc)
- require "fingerpoken/xdo"
- target = FingerPoken::Target::Xdo.new :channel => channel
-
- #require "fingerpoken/vnc"
- #target = FingerPoken::Target::VNC.new :channel => channel
+ targets.each do |klass, args|
+ args.merge!({ :channel => channel })
+ puts FingerPoken::Target.const_get(klass).new(args)
+ end
EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 5001) do |ws|
ws.onmessage do |message|
request = JSON.parse(message)
puts "Request: #{request.inspect}"