Sha256: 869ad389712714b0d277b04294d92ca21a0cee485b0f58a12678fc6ebf28bb2e
Contents?: true
Size: 1.57 KB
Versions: 3
Compression:
Stored size: 1.57 KB
Contents
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 o["verbose"] end desc "clean", "clean up files doesn't in rtorrent client" def clean Task.clean end 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 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" 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
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
saber-0.0.7 | lib/saber/cli.rb |
saber-0.0.6 | lib/saber/cli.rb |
saber-0.0.4 | lib/saber/cli.rb |