Class: Saber::CLI
Instance Attribute Summary collapse
-
#o ⇒ Object
readonly
Returns the value of attribute o.
Instance Method Summary collapse
- #clean ⇒ Object
- #client ⇒ Object
- #drb_add(ids_str, label = "") ⇒ Object
- #fetch(*names) ⇒ Object
- #generate(type, filename, *args) ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #make(*files) ⇒ Object
- #send1(*names) ⇒ Object
- #server ⇒ Object
- #upload(*files) ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/saber/cli.rb', line 15 def initialize(*) super o = @o = .dup Saber.ui = if o["log"] then require "logger" UI::Logger.new(::Logger.new(o["log"])) else the_shell = (["no-color"] ? Thor::Shell::Basic.new : shell) UI::Shell.new(the_shell) end Saber.ui.debug! if o["verbose"] # Initialize environment in first time unless Rc.p.home.exists? Pa.mkdir Rc.p.home end end |
Instance Attribute Details
#o ⇒ Object (readonly)
Returns the value of attribute o.
13 14 15 |
# File 'lib/saber/cli.rb', line 13 def o @o end |
Instance Method Details
#clean ⇒ Object
36 37 38 39 40 |
# File 'lib/saber/cli.rb', line 36 def clean require "saber/task/clean" Task["clean"].invoke(:clean, [], o) end |
#client ⇒ Object
48 49 50 |
# File 'lib/saber/cli.rb', line 48 def client AutoFetcher::Client.start end |
#drb_add(ids_str, label = "") ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/saber/cli.rb', line 53 def drb_add(ids_str, label="") return if label != "saber" require "drb" require "retort" Retort::Service.configure { |c| c.url = Rc.scgi_server } names = ids_str.split(",").map{|v| Retort::Torrent.action("name", v)} AutoFetcher::DRbClient.new.add(*names) end |
#fetch(*names) ⇒ Object
81 82 83 |
# File 'lib/saber/cli.rb', line 81 def fetch(*names) Fetcher.new.add_names(*names) end |
#generate(type, filename, *args) ⇒ Object
73 74 75 76 77 |
# File 'lib/saber/cli.rb', line 73 def generate(type, filename, *args) require "saber/task/generate" Task["generate"].invoke(:generate, [["tracker"] || ENV["SABER_TRACKER"], type, filename, *args], o) end |
#make(*files) ⇒ Object
93 94 95 96 97 |
# File 'lib/saber/cli.rb', line 93 def make(*files) require "saber/task/make" Task["make"].invoke(:make, [["tracker"] || ENV["SABER_TRACKER"], *files], o) end |
#send1(*names) ⇒ Object
86 87 88 89 90 |
# File 'lib/saber/cli.rb', line 86 def send1(*names) require "saber/task/send" Task["send"].invoke(:send1, names, o) end |
#server ⇒ Object
43 44 45 |
# File 'lib/saber/cli.rb', line 43 def server AutoFetcher::Server.start end |
#upload(*files) ⇒ Object
66 67 68 69 70 |
# File 'lib/saber/cli.rb', line 66 def upload(*files) require "saber/task/upload" Task["upload"].invoke(:upload, [["tracker"] || ENV["SABER_TRACKER"], *files], o) end |