lhj-tools 0.1.99 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c1cb1e36ca0a061c4d3e53f5c0af5c0fb43f5c3dbb044fdd512c44f806a585d
4
- data.tar.gz: 1ea501e7dde6f267da843ba2aa0f304e2ec038d0ed16f9a4b7348988d982ffab
3
+ metadata.gz: 7f059ba0c12401b26f210d4e3d1215168516aeccae1a1b1799b5ce01d1b1846c
4
+ data.tar.gz: '01386ae62655563b81f2ae08f7a19fa3a3cfa664f7fcc0dab34f5ddeba3c70b2'
5
5
  SHA512:
6
- metadata.gz: 04faa27361e9e260282b8ed9eaaec6d11336c7f5b4af80c069fc6f37956a485a178880ce6397aca1452d14fad32a47059b699bed3e6a67b75e98a5e57bc0921a
7
- data.tar.gz: 6411de6c950b82eafcf5727c57cbd758a6d3350c1682171ba4bc589ad0ddde95b4a53344cf21b03148834af823f35f27bc0ce98585bfb682d744594257aa5ea8
6
+ metadata.gz: f62dae3e2bf5e873bb778e4a796b60bd9d9569bd8491dd30f4f5c42cba02f8860cfff798d8b578b7c0433684f6256320b2afaa6c5a6461ebd80198981cd458cc
7
+ data.tar.gz: fbebce23c7af7d7591a2788581d3e9f8df9672fc64b4bd428daf925d8ad883eb5dc658625a8924c2b6885b28ec48d028f3c3be84fbb2fafc932f655ba1739e73
@@ -9,20 +9,31 @@ module Lhj
9
9
  def self.options
10
10
  [
11
11
  %w[--save 保存文件],
12
- %w[--clear 清空控制台输出]
12
+ %w[--clear 清空控制台输出],
13
+ %w[--all_folder 列出所有的子目录],
14
+ %w[--prefix 前缀过滤],
15
+ %w[--marker key之后的列表数据]
13
16
  ]
14
17
  end
15
18
 
16
19
  def initialize(argv)
17
20
  @save = argv.flag?('save', false)
18
21
  @clear = argv.flag?('clear', false)
22
+ @all_folder = argv.flag?('all_folder', false)
23
+ @prefix = argv.option('prefix')
24
+ @marker = argv.option('marker')
19
25
  @current_path = argv.shift_argument || Dir.pwd
20
26
  super
21
27
  end
22
28
 
23
29
  def handle
24
- objects = Lhj::OSS::Helper.instance.list
25
- obj_keys = objects.map(&:key)
30
+ list_opts = {}
31
+ list_opts[:prefix] = @prefix if @prefix
32
+ list_opts[:marker] = @marker if @marker
33
+ list_opts[:delimiter] = '/' if @all_folder
34
+ objects = Lhj::OSS::Helper.instance.list(list_opts)
35
+ obj_keys = objects.map(&:key) unless @all_folder
36
+ obj_keys = objects.filter { |o| o.is_a?(String) } if @all_folder
26
37
  save(obj_keys) if @save
27
38
  print(obj_keys) unless @clear
28
39
  end
@@ -31,14 +42,15 @@ module Lhj
31
42
  obj_urls = obj_keys.map { |k| "#{Lhj::OSS::Helper.instance.url_path}/#{k}" }
32
43
  FileUtils.chdir(@current_path) do
33
44
  File.write('oss_key.yml', obj_keys.to_yaml)
34
- File.write('oss_url.yml', obj_urls.to_yaml)
45
+ File.write('oss_url.yml', obj_urls.to_yaml) unless @all_folder
35
46
  end
36
47
  end
37
48
 
38
49
  def print(obj_keys)
39
50
  rows = []
40
51
  obj_keys.each_with_index do |k, i|
41
- path = "#{i}.#{Lhj::OSS::Helper.instance.url_path}/#{k}"
52
+ path = "#{i}.#{Lhj::OSS::Helper.instance.url_path}/#{k}" unless @all_folder
53
+ path = k if @all_folder
42
54
  rows << [path]
43
55
  end
44
56
  table = Terminal::Table.new title: 'OSS List', headings: ['URL'], rows: rows
@@ -6,8 +6,15 @@ module Lhj
6
6
  class OSS < Command
7
7
  class UpdateBucket < OSS
8
8
 
9
+ def self.options
10
+ [
11
+ %w[--idx 最新bucket序号]
12
+ ]
13
+ end
14
+
9
15
  def initialize(argv)
10
16
  @cli = HighLine.new
17
+ @idx = argv.option('idx')
11
18
  super
12
19
  end
13
20
 
@@ -16,8 +23,10 @@ module Lhj
16
23
  return unless bucket_list.length.positive?
17
24
 
18
25
  bucket_list.each_with_index { |k, i| puts "#{i}.#{k['name']}----#{k['location']}".yellow }
19
- idx = @cli.ask('更新序号: '.green).strip.to_i
26
+ idx = @idx.to_i if @idx
27
+ idx = @cli.ask('更新序号: '.green).strip.to_i unless @idx
20
28
  bucket = bucket_list[idx]
29
+ puts "update: #{bucket['name']} -- #{bucket['location']}"
21
30
  Lhj::OSSConfig.oss_endpoint = "#{bucket['location']}.aliyuncs.com"
22
31
  Lhj::OSSConfig.oss_bucket = bucket['name']
23
32
  Lhj::OSSConfig.save
@@ -15,7 +15,8 @@ module Lhj
15
15
 
16
16
  def self.options
17
17
  [
18
- %w[--tag 标签]
18
+ %w[--tag 标签],
19
+ %w[--oss_key 指定oss_key的名称]
19
20
  ]
20
21
  end
21
22
 
@@ -41,8 +41,11 @@ module Lhj
41
41
  @bucket.object_url(key, false)
42
42
  end
43
43
 
44
- def list
45
- @bucket.list_objects
44
+ # @bucket.list_objects({ prefix: 'tool/config' }) 前缀过滤
45
+ # @bucket.list_objects({ marker: 'code/README.md' }) 当前key之前后
46
+ # @bucket.list_objects({ delimiter: '/' }).filter { |o| o.is_a?(String) } 分割符, 获取所有目录结构
47
+ def list(opts = {})
48
+ @bucket.list_objects(opts)
46
49
  end
47
50
 
48
51
  # {bucket.name} #{bucket.location}
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lhj
4
4
  module Tools
5
- VERSION = "0.1.99"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhj-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.99
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - lihaijian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-18 00:00:00.000000000 Z
11
+ date: 2023-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj