lhj-tools 0.1.2 → 0.1.6

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: f2210e536172e4943d1e39f4460cd715ef726e35b0859c348b24963a1f0ff433
4
- data.tar.gz: c1e81cf0c82016ee20f57168c840780cd7127a28a1c2c92d409785f03a52dbe5
3
+ metadata.gz: 2d7427bf47063e690b70a09d1bf6987c387d7289ec0c4206fd7d6182372e463e
4
+ data.tar.gz: d43905b649b15c84de3120b966c42ebb684bdacfec57af0ac2c622fb57218c79
5
5
  SHA512:
6
- metadata.gz: 8cd06e57308f22d90b13d330f21a6c198d873a5483ae604c044e3c0fbd76c8083550fb261e30fc40f43b8e1af8f891063b0ba7a7930a258de8cf1f8292855802
7
- data.tar.gz: 2428331f080d48dac6ae877c179a900ddb2601a32c292062d2edbfa7febb1a202dda40fd7fe21f6d840dffad0335695ad1c306c6ea9903a99bd2895cead8edc4
6
+ metadata.gz: 5c3f50b5221b68bdec3d7257c31456a70f9fc04263fd48ce4007157b638ab96613a8077339ae016126c9abf0cb75bc2d35f5bb6ef98f70ca55d3310512e21171
7
+ data.tar.gz: 0bbff5886d4a5aace7ad8c2143db0fbfe7a7c52cf5809e62a6325a478f7c9c045aede8f74eea640e5a366b38cc6f203e87c372187a257452b65e557d5e87eec3
@@ -1,12 +1,21 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+ require 'net/http'
4
+ require 'uri'
5
+ require 'lhj/config'
1
6
 
2
7
  module Lhj
3
8
  class Command
4
- # init tools
9
+ # sync config
5
10
  class Init < Command
6
11
  self.summary = '初始化控件'
12
+ self.description = '使用工具前先执行`lhj init`'
7
13
 
8
14
  def run
9
- p 'hello world'
15
+ auto_spin
16
+ FileUtils.mkdir_p(target_folder) unless File.exist?(target_folder)
17
+ download_file
18
+ stop
10
19
  end
11
20
 
12
21
  def down_load_urls
@@ -16,11 +25,29 @@ module Lhj
16
25
  http://aomi-ios-repo.oss-cn-shenzhen.aliyuncs.com/zh2hant.yml]
17
26
  end
18
27
 
19
- def down_load_file
20
- ary = down_load_urls
21
- ary.each do |key|
28
+ def target_folder
29
+ Lhj::Config.instance.home_dir
30
+ end
31
+
32
+ def save_file(url, target)
33
+ http_client = Faraday.new do |c|
34
+ c.adapter Faraday.default_adapter
35
+ end
36
+ response = http_client.get(url)
37
+ File.open(target, 'wb') { |fp| fp.write(response.body) }
38
+ end
39
+
40
+ def file_name_with_url(url)
41
+ url.scan(%r{/([^/]+)}).flatten.last
42
+ end
43
+
44
+ def download_file
45
+ down_load_urls.each do |url|
46
+ file_name = file_name_with_url(url)
47
+ file_path = File.join(target_folder, file_name)
48
+ save_file(url, file_path) unless File.exist?(file_path)
22
49
  end
23
- puts "同步完成 \n"
50
+ puts "工具初始化完成 \n"
24
51
  end
25
52
  end
26
53
  end
@@ -8,27 +8,40 @@ module Lhj
8
8
  self.summary = '删除OSS的key'
9
9
 
10
10
  self.arguments = [
11
- CLAide::Argument.new('--key=XX', true)
11
+ CLAide::Argument.new('--key=XX', true),
12
+ CLAide::Argument.new('--type=XX', true)
12
13
  ]
13
14
 
14
15
  def self.options
15
16
  [
16
- %w[--key OSS对应的key]
17
+ %w[--key OSS对应的key],
18
+ %w[--type OSS对应的类型]
17
19
  ]
18
20
  end
19
21
 
20
22
  def initialize(argv)
21
23
  @key = argv.option('key')
24
+ @type = argv.option('type')
22
25
  super
23
26
  end
24
27
 
25
28
  def validate!
26
- help! '请输入key' unless @key
29
+ help! '请输入key或者类型' unless @key || @type
27
30
  super
28
31
  end
29
32
 
30
33
  def run
31
- Lhj::OSS::Helper.instance.delete(@key)
34
+ if @type
35
+ objects = Lhj::OSS::Helper.instance.list
36
+ objects.each do |o|
37
+ if /#{@type}/ =~ o.key
38
+ puts "成功删除#{o.key}"
39
+ Lhj::OSS::Helper.instance.delete(o.key)
40
+ end
41
+ end
42
+ else
43
+ Lhj::OSS::Helper.instance.delete(@key)
44
+ end
32
45
  end
33
46
  end
34
47
  end
@@ -1,15 +1,21 @@
1
1
  require 'lhj/helper/oss_helper'
2
+ require 'terminal-table'
2
3
 
3
4
  module Lhj
4
5
  class Command
5
6
  class OSS < Command
6
7
  class List < OSS
8
+ self.summary = '查看oss列表'
9
+
7
10
  def run
8
11
  objects = Lhj::OSS::Helper.instance.list
12
+ rows = []
9
13
  objects.each do |o|
10
14
  path = "#{Lhj::OSS::Helper.instance.url_path}/#{o.key}"
11
- puts path
15
+ rows << [path]
12
16
  end
17
+ table = Terminal::Table.new title: 'OSS List', headings: ['URL'], rows: rows
18
+ puts table
13
19
  end
14
20
  end
15
21
  end
@@ -11,30 +11,33 @@ module Lhj
11
11
 
12
12
  self.arguments = [
13
13
  CLAide::Argument.new('type', false),
14
- CLAide::Argument.new('name', false)
14
+ CLAide::Argument.new('name', false),
15
+ CLAide::Argument.new('tag', false)
15
16
  ]
16
17
 
17
18
  def self.options
18
19
  [
19
20
  %w[--type 文件类型],
20
- %w[--name 文件名]
21
+ %w[--name 文件名],
22
+ %w[--tag 标签]
21
23
  ]
22
24
  end
23
25
 
24
26
  def validate!
25
27
  super
26
- help! '类型或名字必须输入' unless @name && @type
28
+ help! '类型或名字必须输入' unless @name || @type
27
29
  end
28
30
 
29
31
  def initialize(argv)
30
32
  @current_path = argv.shift_argument || Dir.pwd
31
33
  @type = argv.option('type')
32
34
  @name = argv.option('name')
35
+ @tag = argv.option('tag')
33
36
  super
34
37
  end
35
38
 
36
39
  def run
37
- Dir.glob(@current_path).each do |f|
40
+ Dir.glob("#{@current_path}/*").each do |f|
38
41
  file_name = File.basename(f)
39
42
  if @name && /#{@name}/ =~ file_name
40
43
  upload(f, file_name)
@@ -48,6 +51,7 @@ module Lhj
48
51
 
49
52
  def upload(file, file_name)
50
53
  oss_key = file_name
54
+ oss_key = "#{@tag}/#{file_name}" if @tag
51
55
  Lhj::OSS::Helper.instance.upload(oss_key, file)
52
56
  url = Lhj::OSS::Helper.instance.object_url(oss_key)
53
57
  puts "云端上传成功:#{url}\n"
@@ -0,0 +1,10 @@
1
+
2
+ module Lhj
3
+ class Command
4
+ # sync config
5
+ class OSS < Command
6
+ self.summary = 'oss操作'
7
+ self.abstract_command = true
8
+ end
9
+ end
10
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'find'
4
4
  require 'fileutils'
5
+ require 'terminal-table'
5
6
 
6
7
  module Lhj
7
8
  class Command
@@ -31,11 +32,13 @@ module Lhj
31
32
  @current_path = argv.shift_argument || Dir.pwd
32
33
  @key = argv.option('key')
33
34
  @other = argv.option('other')
35
+ @modify_files = []
34
36
  super
35
37
  end
36
38
 
37
39
  def run
38
40
  update_source_file
41
+ print_info
39
42
  end
40
43
 
41
44
  def update_source_file
@@ -69,9 +72,22 @@ module Lhj
69
72
 
70
73
  def format_string(file, line)
71
74
  result = line
72
- result = result.gsub(/(\W)(#{@key})(\W)/, "\\1#{@other}\\3") if /(\W)(#{@key})(\W)/ =~ line
75
+ if /(\W)(#{@key})(\W)/ =~ line
76
+ result = result.gsub(/(\W)(#{@key})(\W)/, "\\1#{@other}\\3")
77
+ @modify_files << file unless @modify_files.include?(file)
78
+ end
73
79
  result
74
80
  end
81
+
82
+ def print_info
83
+ rows = []
84
+ @modify_files.each do |file|
85
+ rows << [File.basename(file), File.absolute_path(file)]
86
+ end
87
+ title = "修改了#{rows.count}个文件"
88
+ table = Terminal::Table.new title: title, headings: %w[文件 路径], rows: rows
89
+ puts table
90
+ end
75
91
  end
76
92
  end
77
93
  end
@@ -1,17 +1,59 @@
1
-
2
1
  module Lhj
3
2
  class Command
4
- class Rename < Command
3
+ class RenameImage < Command
4
+ self.summary = '重命名图片'
5
+
6
+ self.arguments = [
7
+ CLAide::Argument.new('--pre=xx', false),
8
+ CLAide::Argument.new('--name=xx', false),
9
+ CLAide::Argument.new('--other=xx', false)
10
+ ]
11
+
12
+ def self.options
13
+ [
14
+ %w[--pre 图片前缀],
15
+ %w[--name 图片名称],
16
+ %w[--other 图片变化后的名称]
17
+ ]
18
+ end
19
+
20
+ def validate!
21
+ super
22
+ help! '输入图片信息' unless @image_pre || @image_name || @image_other_name
23
+ end
24
+
25
+ def initialize(argv)
26
+ @current_path = argv.shift_argument || Dir.pwd
27
+ @image_pre = argv.option('pre')
28
+ @image_name = argv.option('name')
29
+ @image_other_name = argv.option('other')
30
+ super
31
+ end
32
+
5
33
  def run
6
- rename
34
+ rename_image
7
35
  end
8
36
 
9
- def rename
10
- folder_path = "~/Downloads/ss"
11
- Dir.glob("#{folder_path}/**/*.{png}").sort.each do |f|
37
+ def rename_image
38
+ Dir.glob("#{@current_path}/**/*.{png}").sort.each do |f|
12
39
  filename = File.basename(f, File.extname(f))
13
- File.rename(f, "#{folder_path}/aomi_soldout_" + filename.capitalize + File.extname(f))
40
+ m_filename = modify_name(filename, File.extname(f))
41
+ target = File.join(@current_path, m_filename)
42
+ File.rename(f, target)
43
+ end
44
+ end
45
+
46
+ def modify_name(file_name, extname)
47
+ name = file_name.downcase + extname
48
+ if @image_pre
49
+ name = @image_pre + file_name.downcase + extname
50
+ elsif @image_name && @image_other_name
51
+ if file_name =~ /#{@image_name}/
52
+ other_name = file_name.gsub(/#{@image_name}/, @image_other_name)
53
+ name = other_name + extname
54
+ end
14
55
  end
56
+ name
15
57
  end
16
58
  end
17
59
  end
@@ -5,6 +5,7 @@ module Lhj
5
5
  class Command
6
6
  class Trans < Command
7
7
  self.summary = '源码中的简繁体转换'
8
+ self.description = '当前目录简繁体转换 `lhj trans --zh-cn`'
8
9
 
9
10
  def self.options
10
11
  [
@@ -1,7 +1,8 @@
1
1
  module Lhj
2
2
  class Command
3
3
  class View < Command
4
- self.summary = '生成源码'
4
+ self.summary = '生成iOS组件源码'
5
+ self.description = '使用`lhj view --type=UILabel --name=titleLabel`'
5
6
 
6
7
  def initialize(argv)
7
8
  @name = argv.option('name', 'titleLabel')
@@ -10,24 +11,25 @@ module Lhj
10
11
  end
11
12
 
12
13
  def names
13
- @name.split(",").map(&:strip)
14
+ @name.split(',').map(&:strip)
14
15
  end
15
16
 
16
17
  def type
17
18
  @ele_type ||= begin
18
- if @type =~ /image/i
19
+ case @type
20
+ when /image/i
19
21
  'UIImageView'
20
- elsif @type =~ /stack/i
22
+ when /stack/i
21
23
  'UIStackView'
22
- elsif @type =~ /label/i
24
+ when /label/i
23
25
  'UILabel'
24
- elsif @type =~ /table/i
26
+ when /table/i
25
27
  'UITableView'
26
- elsif @type =~ /text/i
28
+ when /text/i
27
29
  'UITextField'
28
- elsif @type =~ /button/i
30
+ when /button/i
29
31
  'UIButton'
30
- elsif @type =~ /view/i
32
+ when /view/i
31
33
  'UIView'
32
34
  else
33
35
  @type
@@ -47,7 +49,7 @@ module Lhj
47
49
 
48
50
  def print_declare
49
51
  names.each do |name|
50
- puts "///"
52
+ puts '///'
51
53
  puts "@property (nonatomic, strong) #{type} *#{name};"
52
54
  end
53
55
  end
@@ -55,24 +57,25 @@ module Lhj
55
57
  def print_instance
56
58
  names.each do |name|
57
59
  puts "-(#{type} *)#{name}"
58
- puts "{"
60
+ puts '{'
59
61
  puts " if(!_#{name}){"
60
62
  print_alloc(name)
61
63
  puts " _#{name}.translatesAutoresizingMaskIntoConstraints = NO;"
62
64
  print_property(name)
63
- puts " }"
65
+ puts ' }'
64
66
  puts " return _#{name};"
65
- puts "}"
67
+ puts '}'
66
68
  puts "\n"
67
69
  end
68
70
  end
69
71
 
70
72
  def print_alloc(name)
71
- if type.eql?('UIImageView')
73
+ case type
74
+ when 'UIImageView'
72
75
  puts " _#{name} = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@\"xxxx\"]];"
73
- elsif type.eql?('UIButton')
76
+ when 'UIButton'
74
77
  puts " _#{name} = [UIButton buttonWithType:UIButtonTypeCustom];"
75
- elsif type.eql?('UITableView')
78
+ when 'UITableView'
76
79
  puts " _#{name} = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];"
77
80
  else
78
81
  puts " _#{name} = [[#{type} alloc] init];"
@@ -80,34 +83,35 @@ module Lhj
80
83
  end
81
84
 
82
85
  def print_property(name)
83
- if type.eql?('UILabel')
86
+ case type
87
+ when 'UILabel'
84
88
  puts " _#{name}.textColor = kSetCOLOR(0x333333);"
85
89
  puts " _#{name}.text = @\"xxxxxxxx\";"
86
90
  puts " _#{name}.font = [UIFont systemFontOfSize:12.0 weight:UIFontWeightRegular];"
87
91
  puts " _#{name}.textAlignment = NSTextAlignmentCenter;"
88
- elsif type.eql?('UIImageView')
92
+ when 'UIImageView'
89
93
  puts " _#{name}.backgroundColor = kBackgroundColor;"
90
94
  puts " _#{name}.contentMode = UIViewContentModeScaleAspectFit;"
91
95
  puts " _#{name}.clipsToBounds = YES;"
92
96
  puts " _#{name}.layer.cornerRadius = 6.0f;"
93
97
  puts " _#{name}.layer.borderColor = kLineColor.CGColor;"
94
98
  puts " _#{name}.layer.borderWidth = 0.5;"
95
- elsif type.eql?('UITextField')
99
+ when 'UITextField'
96
100
  puts " _#{name}.textColor = kSetCOLOR(0x333333);"
97
101
  puts " _#{name}.font = [UIFont systemFontOfSize:12.0 weight:UIFontWeightRegular];"
98
- elsif type.eql?('UIView')
102
+ when 'UIView'
99
103
  puts " _#{name}.backgroundColor = kBackgroundColor;"
100
- elsif type.eql?('UIStackView')
104
+ when 'UIStackView'
101
105
  puts " _#{name}.axis = UILayoutConstraintAxisHorizontal;"
102
106
  puts " _#{name}.distribution = UIStackViewDistributionFillEqually;"
103
- elsif type.eql?('UITableView')
107
+ when 'UITableView'
104
108
  puts " _#{name}.backgroundColor = kBackgroundColor;"
105
109
  puts " _#{name}.delegate = self;"
106
110
  puts " _#{name}.delegate = self;"
107
111
  puts " _#{name}.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];"
108
112
  puts " _#{name}.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];"
109
113
  puts " _#{name}.separatorStyle = UITableViewCellSeparatorStyleNone;"
110
- elsif type.eql?('UIButton')
114
+ when 'UIButton'
111
115
  puts " _#{name}.backgroundColor = kBackgroundColor;"
112
116
  puts " [_#{name} setTitle:@\"xxx\" forState:UIControlStateNormal];"
113
117
  puts " [_#{name} setTitleColor:kSetCOLOR(0x999999) forState:UIControlStateNormal];"
@@ -7,6 +7,7 @@ module Lhj
7
7
  class Command
8
8
  class Yapi < Command
9
9
  self.summary = '通过yapi接口生成请求'
10
+ self.description = '更新 ~/.lhj/yapi.yml 文件配置后执行`lhj api`生成接口模型'
10
11
 
11
12
  def self.options
12
13
  [
@@ -43,8 +44,8 @@ module Lhj
43
44
  def test_ding
44
45
  require 'net/http'
45
46
  require 'uri'
46
- body = { "msgtype" => "text", "text" => { "content" => "error:上传蒲公英超时失败!" } }.to_json
47
- Net::HTTP.post(URI('https://oapi.dingtalk.com/robot/send?access_token=6a3519057170cdb1b7274edfe43934c84a0062ffe2c9bcced434699296a7e26e'), body, "Content-Type" => "application/json")
47
+ body = { 'msgtype' => 'text', 'text' => { 'content' => 'error:上传蒲公英超时失败!' } }.to_json
48
+ Net::HTTP.post(URI('https://oapi.dingtalk.com/robot/send?access_token=6a3519057170cdb1b7274edfe43934c84a0062ffe2c9bcced434699296a7e26e'), body, 'Content-Type' => 'application/json')
48
49
  end
49
50
 
50
51
  def puts_h(str)
@@ -178,7 +179,8 @@ module Lhj
178
179
  p_model = { name: p_name }
179
180
 
180
181
  properties = []
181
- if p_type.eql?('object')
182
+ case p_type
183
+ when 'object'
182
184
  p_properties.each do |k, v|
183
185
  c_type = @type_trans[v['type']] || v['type']
184
186
  c_model = { key: k, type: c_type, description: v['description'], default: '' }
@@ -186,7 +188,7 @@ module Lhj
186
188
  o = v['items'] || v
187
189
  o['name'] = gen_model_name(k)
188
190
  if v['type'].eql?('array') && v['items']['type'].eql?('string')
189
- c_model[:type_name] = "NSString"
191
+ c_model[:type_name] = 'NSString'
190
192
  else
191
193
  c_model[:type_name] = o['name']
192
194
  handle_model(o)
@@ -196,7 +198,7 @@ module Lhj
196
198
  end
197
199
  p_model[:properties] = properties
198
200
  @models << p_model
199
- elsif p_type.eql?('array')
201
+ when 'array'
200
202
  t = model['items']
201
203
  t['name'] = p_name
202
204
  handle_model(t)
@@ -220,9 +222,9 @@ module Lhj
220
222
  puts_m "@implementation #{model[:name]}"
221
223
  str = model[:properties].filter { |p| p[:type].eql?('array') && !p[:type_name].eql?('NSString') }.map { |p| "@\"#{p[:key]}\": #{p[:type_name]}.class" }.join(', ')
222
224
  if str && str.length > 0
223
- puts_m "+(NSDictionary *)modelContainerPropertyGenericClass {"
225
+ puts_m '+(NSDictionary *)modelContainerPropertyGenericClass {'
224
226
  puts_m " return @{#{str}};"
225
- puts_m "}"
227
+ puts_m '}'
226
228
  end
227
229
  puts_m "@end\n"
228
230
  puts "\n\n"
@@ -237,27 +239,28 @@ module Lhj
237
239
  des.gsub!(/\n/, ' ')
238
240
  default = m[:default]
239
241
  puts_h "///#{des} #{default}"
240
- if type.eql?('integer')
242
+ case type
243
+ when 'integer'
241
244
  puts_h "@property (nonatomic, assign) NSInteger #{key};"
242
245
  if des.include?('分')
243
- puts_h "/////////==========删掉其中一个属性"
246
+ puts_h '/////////==========删掉其中一个属性'
244
247
  puts_h "@property (nonatomic, strong) MLCentNumber *#{key};"
245
248
  end
246
- elsif type.eql?('cent')
249
+ when 'cent'
247
250
  puts_h "@property (nonatomic, strong) MLCentNumber *#{key};"
248
- elsif type.eql?('string')
251
+ when 'string'
249
252
  puts_h "@property (nonatomic, copy) NSString *#{key};"
250
- elsif type.eql?('number')
253
+ when 'number'
251
254
  puts_h "@property (nonatomic, strong) NSNumber *#{key};"
252
- elsif type.eql?('float')
255
+ when 'float'
253
256
  puts_h "@property (nonatomic, assign) CGFloat #{key};"
254
- elsif type.eql?('double')
257
+ when 'double'
255
258
  puts_h "@property (nonatomic, assign) double #{key};"
256
- elsif type.eql?('boolean')
259
+ when 'boolean'
257
260
  puts_h "@property (nonatomic, assign) BOOL #{key};"
258
- elsif type.eql?('object')
261
+ when 'object'
259
262
  puts_h "@property (nonatomic, strong) #{type_name} *#{key};"
260
- elsif type.eql?('array')
263
+ when 'array'
261
264
  puts_h "@property (nonatomic, strong) NSArray<#{type_name} *> *#{key};"
262
265
  else
263
266
  puts_h "@property (nonatomic, copy) NSString *#{key};"
@@ -266,36 +269,36 @@ module Lhj
266
269
 
267
270
  def print_methods
268
271
  puts "\n<===============方法调用=====================>\n"
269
- puts_m "/**"
272
+ puts_m '/**'
270
273
  puts_m " * #{@data_json['title']} -- #{@data_json['username']}"
271
- puts_m " */"
274
+ puts_m ' */'
272
275
  key_str = @data_json['path'].split('/').map { |s| s.gsub(/[^A-Za-z0-9]/, '').gsub(/^\w/) { $&.upcase } }.join('')
273
276
  key = "k#{key_str}URL"
274
277
  puts_m "static NSString * const #{key} = @\"#{@data_json['path']}\";"
275
278
  puts_m "\n\n"
276
- puts_h "@interface MLParamModel : NSObject"
279
+ puts_h '@interface MLParamModel : NSObject'
277
280
  @data_json['req_query'].each do |h|
278
281
  des = h['desc']
279
282
  puts_h "///#{des} #{h['example']}"
280
283
  puts_h "@property (nonatomic, copy) NSString *#{h['name']};"
281
284
  end
282
- puts_h "@end"
285
+ puts_h '@end'
283
286
  puts "\n\n"
284
287
  model = @models.last
285
288
  if @data_json['method'].eql?('GET')
286
289
  puts_m " [MLNetworkingManager getWithUrl:#{key} params:nil response:^(MLResponseMessage *responseMessage) {"
287
- puts_m " if (response.resultCode == 0 && !response.error){"
288
- puts_m " NSDictionary *detailMsg = response.detailMsg"
290
+ puts_m ' if (response.resultCode == 0 && !response.error){'
291
+ puts_m ' NSDictionary *detailMsg = response.detailMsg'
289
292
  puts_m " #{model[:name]} *model = [#{model[:name]} yy_modelWithDictionary:detailMsg];" if model
290
- puts_m " }"
291
- puts_m " }];"
293
+ puts_m ' }'
294
+ puts_m ' }];'
292
295
  else
293
296
  puts_m " [MLNetworkingManager postWithUrl:#{key} params:nil response:^(MLResponseMessage *responseMessage) {"
294
- puts_m " if (response.resultCode == 0 && !response.error){"
295
- puts_m " NSDictionary *detailMsg = response.detailMsg"
297
+ puts_m ' if (response.resultCode == 0 && !response.error){'
298
+ puts_m ' NSDictionary *detailMsg = response.detailMsg'
296
299
  puts_m " #{model[:name]} *model = [#{model[:name]} yy_modelWithDictionary:detailMsg];" if model
297
- puts_m " }"
298
- puts_m " }];"
300
+ puts_m ' }'
301
+ puts_m ' }];'
299
302
  end
300
303
  end
301
304
  end
data/lib/lhj/command.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'claide'
2
+ require "tty-spinner"
2
3
 
3
4
  module Lhj
5
+ # command plugin
4
6
  class Command < CLAide::Command
5
7
  require 'lhj/command/init'
6
8
  require 'lhj/command/head_import'
@@ -10,6 +12,7 @@ module Lhj
10
12
  require 'lhj/command/local/local'
11
13
  require 'lhj/command/local/micro_service'
12
14
  require 'lhj/command/local/local_upload'
15
+ require 'lhj/command/oss'
13
16
  require 'lhj/command/oss/del'
14
17
  require 'lhj/command/oss/upload'
15
18
  require 'lhj/command/oss/list'
@@ -20,5 +23,19 @@ module Lhj
20
23
 
21
24
  self.abstract_command = true
22
25
  self.command = 'lhj'
26
+
27
+ def spinner
28
+ @spinner ||= TTY::Spinner.new('[:spinner]正在处理...', output: $stdout, format: :dots)
29
+ end
30
+
31
+ def auto_spin
32
+ spinner.auto_spin
33
+ puts "\n"
34
+ end
35
+
36
+ def stop
37
+ spinner.stop('Done!')
38
+ end
39
+
23
40
  end
24
- end
41
+ end