Class: Lhj::Command::OSS::UpdateBucket
- Inherits:
-
Lhj::Command::OSS
- Object
- CLAide::Command
- Lhj::Command
- Lhj::Command::OSS
- Lhj::Command::OSS::UpdateBucket
- Defined in:
- lib/lhj/command/oss/update_bucket.rb
Class Method Summary collapse
Instance Method Summary collapse
- #handle ⇒ Object
-
#initialize(argv) ⇒ UpdateBucket
constructor
A new instance of UpdateBucket.
Methods inherited from Lhj::Command
#auto_spin, #begin_title, #run, #stop
Constructor Details
#initialize(argv) ⇒ UpdateBucket
Returns a new instance of UpdateBucket.
15 16 17 18 19 |
# File 'lib/lhj/command/oss/update_bucket.rb', line 15 def initialize(argv) @cli = HighLine.new @idx = argv.option('idx') super end |
Class Method Details
.options ⇒ Object
9 10 11 12 13 |
# File 'lib/lhj/command/oss/update_bucket.rb', line 9 def self. [ %w[--idx 最新bucket序号] ] end |
Instance Method Details
#handle ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lhj/command/oss/update_bucket.rb', line 21 def handle bucket_list = Lhj::OSSConfig.oss_bucket_list return unless bucket_list.length.positive? bucket_list.each_with_index { |k, i| puts "#{i}.#{k['name']}----#{k['location']}".yellow } idx = @idx.to_i if @idx idx = @cli.ask('更新序号: '.green).strip.to_i unless @idx bucket = bucket_list[idx] puts "update: #{bucket['name']} -- #{bucket['location']}" Lhj::OSSConfig.oss_endpoint = "#{bucket['location']}.aliyuncs.com" Lhj::OSSConfig.oss_bucket = bucket['name'] Lhj::OSSConfig.oss_domain = bucket['domain'] Lhj::OSSConfig.save end |