Sha256: 23d3b016cfb3e4278820e63975050bb969f4671b70a6d15aa94fbd2772f50092
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true require 'lhj/helper/oss_helper' require 'highline' module Lhj class Command class OSS < Command class Del < OSS def initialize(argv) @cli = HighLine.new super end 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('请选择删除的key: '.green) idx_arr = idx.split(',').map(&:strip).filter { |v| v.length.positive? } result_keys = [] idx_arr.each do |i| ma = /(?<begin>[0-9]*)\D*-\D*(?<end>[0-9]*)/.match(i) result_keys << obj_keys[ma[:begin].to_i..ma[:end].to_i] if ma result_keys << obj_keys[i.to_i] unless ma end oss_keys = result_keys.flatten oss_keys.each do |oss_key| puts "删除的key为:#{oss_key}".red end Lhj::OSS::Helper.instance.batch_delete(oss_keys) if oss_keys.length > 0 end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lhj-tools-0.1.98 | lib/lhj/command/oss/del.rb |