Class: Baidupan::Cmd::FsCmd
- Inherits:
-
Base
- Object
- Thor
- Base
- Baidupan::Cmd::FsCmd
show all
- Defined in:
- lib/baidupan/cmd/fs_cmd.rb
Instance Method Summary
collapse
Methods inherited from Base
#config, #setup, #show_config
Instance Method Details
#download(rpath, lpath = nil) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/baidupan/cmd/fs_cmd.rb', line 40
def download(rpath, lpath=nil)
lpath = (lpath||rpath).dup
res = Baidupan::FsCmd.download(rpath, lpath, options.dup)
if File.exists?(lpath)
extname = File.extname(lpath)
timestamp_name = "_#{Time.now.strftime(Baidupan::Config.time_format)}_#{rand(10)}#{extname}"
if extname.empty?
lpath += timestamp_name
else
lpath.gsub!(extname, timestamp_name)
end
end
File.binwrite(lpath, res.body)
say "download and save at'#{lpath}'..."
end
|
#list(rpath = nil) ⇒ Object
21
22
23
24
25
26
|
# File 'lib/baidupan/cmd/fs_cmd.rb', line 21
def list(rpath=nil)
res = Baidupan::FsCmd.list(rpath)
res.body[:list].each do |item|
print_item(item)
end
end
|
#upload(lpath, rpath = nil) ⇒ Object
33
34
35
36
|
# File 'lib/baidupan/cmd/fs_cmd.rb', line 33
def upload(lpath, rpath=nil)
res = Baidupan::FsCmd.upload(lpath, rpath, options.dup)
print_item res.body
end
|