Class: Lhj::Command::OSS::Upload
- Inherits:
-
Lhj::Command::OSS
- Object
- CLAide::Command
- Lhj::Command
- Lhj::Command::OSS
- Lhj::Command::OSS::Upload
- Defined in:
- lib/lhj/command/oss/upload.rb
Overview
OSS file upload
Class Method Summary collapse
Instance Method Summary collapse
- #handle ⇒ Object
-
#initialize(argv) ⇒ Upload
constructor
A new instance of Upload.
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
.options ⇒ Object
16 17 18 19 20 |
# File 'lib/lhj/command/oss/upload.rb', line 16 def self. [ %w[--tag 标签] ] end |
Instance Method Details
#handle ⇒ Object
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 |