Commit 5ea4318

mo khan <mo@mokhan.ca>
2014-08-29 03:48:32
add a thor commandline interface.
1 parent 7a28ec5
Changed files (3)
bin/camtasy
@@ -1,3 +1,16 @@
 #!/usr/bin/env ruby
 
 require 'camtasy'
+require "thor"
+
+module Camtasy
+  class CLI < Thor
+    desc 'server', 'starts a server.'
+    def server
+      #PhotoServer.new.run('druby://localhost:8787')
+      puts "server"
+    end
+  end
+end
+
+Camtasy::CLI.start
lib/camtasy/server.rb
@@ -15,7 +15,7 @@ module Camtasy
       end
     end
 
-    def run
+    def run(uri)
       Thread.new do
         AVCapture::Session.new.run_with(AVCapture.devices.find(&:video?)) do |connection|
           while server.request.pop
@@ -24,10 +24,8 @@ module Camtasy
         end
       end
 
-      DRb.start_service('druby://localhost:8787', server)
+      DRb.start_service(uri, server)
       DRb.thread.join
     end
   end
 end
-
-PhotoServer.new.run
camtasy.gemspec
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
   spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
   spec.require_paths = ["lib"]
 
+  spec.add_runtime_dependency "thor", '~> 0.19'
+  spec.add_runtime_dependency "av_capture", '~> 1.0'
   spec.add_development_dependency "bundler", "~> 1.6"
   spec.add_development_dependency "rake"
   spec.add_development_dependency "rspec"