Class: Lhj::Command::OSS::Upload

Inherits:
Lhj::Command::OSS show all
Defined in:
lib/lhj/command/oss/upload.rb

Overview

OSS file upload

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Lhj::Command

#auto_spin, #begin_title, #run, #stop

Constructor Details

#initialize(argv) ⇒ Upload

Returns a new instance of Upload.



22
23
24
25
26
27
# File 'lib/lhj/command/oss/upload.rb', line 22

def initialize(argv)
  @current_path = argv.shift_argument || Dir.pwd
  @tag = argv.option('tag')
  @cli = HighLine.new
  super
end

Class Method Details

.optionsObject



16
17
18
19
20
# File 'lib/lhj/command/oss/upload.rb', line 16

def self.options
  [
    %w[--tag 标签]
  ]
end

Instance Method Details

#handleObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/lhj/command/oss/upload.rb', line 29

def handle
  file_list = []
  file_name_list = []
  Dir.glob("#{@current_path}/*").each_with_index do |f, i|
    file_base_name = File.basename(f)
    file_list << f
    file_name_list << file_base_name
    puts "#{i}.#{file_base_name}".yellow
  end
  idx = @cli.ask('请选择上传文件序号: '.green).strip.to_i
  puts "上传的文件名:#{file_name_list[idx]}".yellow
  upload(file_list[idx], file_name_list[idx])
end