kdeploy 1.0.7 → 1.0.8

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: 15b3fbf88bffba0ba35c0b75e18cf57e5665d6bb512c354835574b07359de60a
4
- data.tar.gz: 5e94c13abd994f4e2e445527aacd42dfd7a7e825f4a78c114b9c5aae78f928b0
3
+ metadata.gz: 71b80d4b4cf5194def86c21793e7a284f524288f06e215fd6d44f0fa408dfe18
4
+ data.tar.gz: d8f28a18304adc12256633567c872d1368a29a644c9e4b1f2cdd44e5ba3d9413
5
5
  SHA512:
6
- metadata.gz: 30e9abe01d5f729092df74cf6065279042421c42bde354c8214a497af56e6d0084f4618ef16ab9ec05d9f9adf9c8b8ab627d7fb22b59b407fdc904cf06917c79
7
- data.tar.gz: 36827e5d4dd7178def48f0602d57ec5c1ee829a163082088915e1aad48f9a98feb00a7f04b6be80b6be802ec9d2ab3fed5b22bb1f3067db022e880f642bf50e9
6
+ metadata.gz: f2e3a70987d5390dc53c4c68091533dfb6f8e9e9b695f03aeaa5c5e1c48c7d646cac698ac5760bb30d5a32a7c1b0ee51ca720e2d9507253d87b2ac01ea0a19ce
7
+ data.tar.gz: b6908b7720edda9e4ff81a2b5f2d679e5ffe7774d62d33de91dd191b5773590020ec49c43b45d58d520da6d7ef6193bca6120e6b7dd1d46b84344081081d80fa
data/lib/kdeploy/cli.rb CHANGED
@@ -177,49 +177,56 @@ module Kdeploy
177
177
 
178
178
  def print_results(results, task_name)
179
179
  pastel = Pastel.new
180
- puts pastel.bright_cyan("\n=== Task: #{task_name} ===\n")
180
+ puts pastel.cyan("\nPLAY [#{task_name}] " + ('*' * 64))
181
181
 
182
182
  results.each do |host, result|
183
- status = result[:status] == :success ? pastel.green('✓ Success') : pastel.red('✗ Failed')
184
- puts pastel.bright_white("[#{host}] #{status}")
185
-
186
- if result[:status] == :success
187
- result[:output].each do |cmd|
188
- # 显示命令
189
- if cmd[:command].include?('<<') || cmd[:command].include?("\n")
190
- first_line = cmd[:command].lines.first.strip
191
- puts pastel.bright_yellow(" $ #{first_line}")
192
- cmd[:command].lines[1..].each do |line|
193
- next if line.strip.empty?
194
-
195
- puts pastel.bright_yellow(" > #{line.strip}")
196
- end
183
+ status = case result[:status]
184
+ when :success then pastel.green('ok')
185
+ when :changed then pastel.yellow('changed')
186
+ else pastel.red('failed')
187
+ end
188
+ puts pastel.bright_white("\n#{host.ljust(24)} : #{status}")
189
+
190
+ if %i[success changed].include?(result[:status])
191
+ result[:output].each do |step|
192
+ if step[:command].to_s.start_with?('upload:')
193
+ puts pastel.green(" [upload] #{step[:command].sub('upload: ', '')}")
194
+ elsif step[:command].to_s.start_with?('upload_template:')
195
+ puts pastel.yellow(" [template] #{step[:command].sub('upload_template: ', '')}")
197
196
  else
198
- puts pastel.bright_yellow(" $ #{cmd[:command].strip}")
199
- end
200
-
201
- # 显示输出
202
- output = cmd[:output].is_a?(Hash) ? cmd[:output][:stdout] : cmd[:output].to_s
203
- output.each_line do |line|
204
- next if line.strip.empty?
205
-
206
- puts pastel.white(" #{line.rstrip}")
207
- end
208
-
209
- # 显示错误输出
210
- if cmd[:output].is_a?(Hash) && !cmd[:output][:stderr].empty?
211
- cmd[:output][:stderr].each_line do |line|
212
- puts pastel.red(" #{line.rstrip}") unless line.strip.empty?
197
+ puts pastel.cyan(" [run] #{step[:command].to_s.lines.first.strip}")
198
+ if step[:output].is_a?(Hash) && step[:output][:stdout]
199
+ step[:output][:stdout].each_line do |line|
200
+ puts " > #{line.strip}" unless line.strip.empty?
201
+ end
202
+ elsif step[:output].is_a?(String)
203
+ step[:output].each_line do |line|
204
+ puts " > #{line.strip}" unless line.strip.empty?
205
+ end
213
206
  end
214
207
  end
215
-
216
- puts
217
208
  end
218
209
  else
219
- puts pastel.red(" #{result[:error]}")
220
- puts
210
+ # 失败主机高亮错误
211
+ err = result[:error] || (if result[:output].is_a?(Array)
212
+ result[:output].map do |o|
213
+ o[:output][:stderr] if o[:output].is_a?(Hash)
214
+ end.compact.join("\n")
215
+ else
216
+ result[:output].to_s
217
+ end)
218
+ puts pastel.red(" ERROR: #{err}")
221
219
  end
222
220
  end
221
+
222
+ # summary
223
+ puts pastel.cyan("\nPLAY RECAP #{'*' * 64}")
224
+ results.each do |host, result|
225
+ ok = %i[success changed].include?(result[:status]) ? result[:output].size : 0
226
+ failed = result[:status] == :failed ? 1 : 0
227
+ changed = result[:status] == :changed ? result[:output].size : 0
228
+ puts "#{host.ljust(24)} : ok=#{ok} changed=#{changed} failed=#{failed}"
229
+ end
223
230
  end
224
231
  end
225
232
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kdeploy
4
- VERSION = '1.0.7'
4
+ VERSION = '1.0.8'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kdeploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kk