lib/saber/cli.rb in saber-0.0.3 vs lib/saber/cli.rb in saber-0.0.4
- old
+ new
@@ -1,19 +1,24 @@
-require "xmlrpc/client"
+require "thor"
+require "drb"
module Saber
class CLI < Thor
include Thor::Actions
class_option "no-color", :type => :boolean, :banner => "Disable colorization in output"
class_option "verbose", :aliases => "-V", :type => :boolean, :banner => "Enable verbose output mode"
+ class_option "log", :banner => "log file", :type => :string
+ attr_reader :o
+
def initialize(*)
super
+ o = @o = options.dup
the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell)
Saber.ui = UI::Shell.new(the_shell)
- Saber.ui.debug! if options["verbose"]
+ Saber.ui.debug! if o["verbose"]
end
desc "clean", "clean up files doesn't in rtorrent client"
def clean
Task.clean
@@ -24,14 +29,22 @@
Downloader.new.add_names(*names)
end
desc "server", "start saber-server daemon"
def server
+ require "logger"
+ o["log"] ||= "/var/log/saber-server.log"
+
+ $log = Logger.new options["verbose"] ? STDOUT : o["log"]
Server.start
end
desc "client", "start saber-client daemon"
def client
+ require "logger"
+ o["log"] ||= "/var/log/saber-client.log"
+
+ $log = Logger.new options["verbose"] ? STDOUT : o["log"]
Client.start
end
desc "drb_add <ids> [label]", "add a file to saber-server daemon via drb"
# drb_add "id1,id2", "foo"