lhj-tools 0.2.0 → 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: bffa0e0d28d2e9c7aa78faecb8d43c884f85ed22da0b852394950f9c8293f996
4
- data.tar.gz: 356b8db34ea4892193716b8373d782949efd63c9c67728ee3d35ca4328cbdfe7
3
+ metadata.gz: 7f059ba0c12401b26f210d4e3d1215168516aeccae1a1b1799b5ce01d1b1846c
4
+ data.tar.gz: '01386ae62655563b81f2ae08f7a19fa3a3cfa664f7fcc0dab34f5ddeba3c70b2'
5
5
  SHA512:
6
- metadata.gz: 88c98dd157029e0b81860405d834111bfc53b15205d1658740d5ae539ae677f87d0915f0e4e1e0d76888808785a10295dbe451394d45c0322475539c3bf3eb44
7
- data.tar.gz: d9d846644b97ea113f8dab060db53f566cab4de1e033a44a406cfa7f35f05a2ad95c3ff803f766ca254aa0e3213b537a9f8524f4d6963b14060bafed7b6fdb80
6
+ metadata.gz: f62dae3e2bf5e873bb778e4a796b60bd9d9569bd8491dd30f4f5c42cba02f8860cfff798d8b578b7c0433684f6256320b2afaa6c5a6461ebd80198981cd458cc
7
+ data.tar.gz: fbebce23c7af7d7591a2788581d3e9f8df9672fc64b4bd428daf925d8ad883eb5dc658625a8924c2b6885b28ec48d028f3c3be84fbb2fafc932f655ba1739e73
@@ -10,6 +10,7 @@ module Lhj
10
10
  [
11
11
  %w[--save 保存文件],
12
12
  %w[--clear 清空控制台输出],
13
+ %w[--all_folder 列出所有的子目录],
13
14
  %w[--prefix 前缀过滤],
14
15
  %w[--marker key之后的列表数据]
15
16
  ]
@@ -18,6 +19,7 @@ module Lhj
18
19
  def initialize(argv)
19
20
  @save = argv.flag?('save', false)
20
21
  @clear = argv.flag?('clear', false)
22
+ @all_folder = argv.flag?('all_folder', false)
21
23
  @prefix = argv.option('prefix')
22
24
  @marker = argv.option('marker')
23
25
  @current_path = argv.shift_argument || Dir.pwd
@@ -28,8 +30,10 @@ module Lhj
28
30
  list_opts = {}
29
31
  list_opts[:prefix] = @prefix if @prefix
30
32
  list_opts[:marker] = @marker if @marker
33
+ list_opts[:delimiter] = '/' if @all_folder
31
34
  objects = Lhj::OSS::Helper.instance.list(list_opts)
32
- obj_keys = objects.map(&:key)
35
+ obj_keys = objects.map(&:key) unless @all_folder
36
+ obj_keys = objects.filter { |o| o.is_a?(String) } if @all_folder
33
37
  save(obj_keys) if @save
34
38
  print(obj_keys) unless @clear
35
39
  end
@@ -38,14 +42,15 @@ module Lhj
38
42
  obj_urls = obj_keys.map { |k| "#{Lhj::OSS::Helper.instance.url_path}/#{k}" }
39
43
  FileUtils.chdir(@current_path) do
40
44
  File.write('oss_key.yml', obj_keys.to_yaml)
41
- File.write('oss_url.yml', obj_urls.to_yaml)
45
+ File.write('oss_url.yml', obj_urls.to_yaml) unless @all_folder
42
46
  end
43
47
  end
44
48
 
45
49
  def print(obj_keys)
46
50
  rows = []
47
51
  obj_keys.each_with_index do |k, i|
48
- 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
49
54
  rows << [path]
50
55
  end
51
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lhj
4
4
  module Tools
5
- VERSION = "0.2.0"
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.2.0
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