Class: Lhj::Command::OSS::Download
- Inherits:
-
Lhj::Command::OSS
- Object
- CLAide::Command
- Lhj::Command
- Lhj::Command::OSS
- Lhj::Command::OSS::Download
- Defined in:
- lib/lhj/command/oss/download.rb
Instance Method Summary collapse
- #handle ⇒ Object
-
#initialize(argv) ⇒ Download
constructor
A new instance of Download.
Methods inherited from Lhj::Command
#auto_spin, #begin_title, #run, #stop
Constructor Details
#initialize(argv) ⇒ Download
Returns a new instance of Download.
11 12 13 14 15 |
# File 'lib/lhj/command/oss/download.rb', line 11 def initialize(argv) @current_path = argv.shift_argument || Dir.pwd @cli = HighLine.new super end |
Instance Method Details
#handle ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/lhj/command/oss/download.rb', line 17 def handle objects = Lhj::OSS::Helper.instance.list obj_keys = [] objects.each_with_index do |o, i| obj_keys << o.key puts "#{i}.#{o.key}".yellow end idx = @cli.ask('请选择下载的序号: '.green).strip.to_i oss_key = obj_keys[idx] puts "下载的key为:#{oss_key}".yellow file_key = oss_key.split('/').last file = File.join(@current_path, file_key) Lhj::OSS::Helper.instance.down_load(oss_key, file) puts "下载文件到目录: #{file}\n".yellow end |