lib/saber/cli.rb in saber-0.0.1 vs lib/saber/cli.rb in saber-0.0.3
- old
+ new
@@ -1,27 +1,47 @@
+require "xmlrpc/client"
+
module Saber
class CLI < Thor
include Thor::Actions
- # check_unknown_options!
-
- # default_task :install
class_option "no-color", :type => :boolean, :banner => "Disable colorization in output"
class_option "verbose", :aliases => "-V", :type => :boolean, :banner => "Enable verbose output mode"
def initialize(*)
super
the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell)
- Bundler.ui = UI::Shell.new(the_shell)
- Bundler.ui.debug! if options["verbose"]
+ Saber.ui = UI::Shell.new(the_shell)
+ Saber.ui.debug! if options["verbose"]
end
desc "clean", "clean up files doesn't in rtorrent client"
def clean
- Task.new.clean
+ Task.clean
end
-private
- # helper methods
+ desc "add <file ..>", "begin download file or directory via aria2 daemon."
+ def add(*names)
+ Downloader.new.add_names(*names)
+ end
+ desc "server", "start saber-server daemon"
+ def server
+ Server.start
+ end
+
+ desc "client", "start saber-client daemon"
+ def client
+ Client.start
+ end
+
+ desc "drb_add <ids> [label]", "add a file to saber-server daemon via drb"
+ # drb_add "id1,id2", "foo"
+ def drb_add(ids_str, label=Rc.label)
+ return if label != Rc.label
+
+ names = ids_str.split(",").map{|v| Retort::Torrent.action("name", v)}
+
+ DRbClient.new.add(*names)
+ end
end
end