Skip to content

Commit b023339

Browse files
committed
Move pretty status printing to Utils namespace and out of commands
1 parent 5f0ace0 commit b023339

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

lib/vmfloaty.rb

+2-18
Original file line numberDiff line numberDiff line change
@@ -427,24 +427,7 @@ def run
427427
if options.json
428428
pp status
429429
else
430-
pools.select! {|name,pool| pool['ready'] < pool['max']} if ! verbose
431-
432-
width = pools.keys.map(&:length).max
433-
pools.each do |name,pool|
434-
begin
435-
max = pool['max']
436-
ready = pool['ready']
437-
pending = pool['pending']
438-
missing = max - ready - pending
439-
char = 'o'
440-
puts "#{name.ljust(width)} #{(char*ready).green}#{(char*pending).yellow}#{(char*missing).red}"
441-
rescue => e
442-
puts "#{name.ljust(width)} #{e.red}"
443-
end
444-
end
445-
446-
puts
447-
puts message.colorize(status['status']['ok'] ? :default : :red)
430+
Utils.prettyprint_status(status, message, pools, verbose)
448431
end
449432

450433
exit status['status']['ok']
@@ -464,6 +447,7 @@ def run
464447

465448
summary = Pooler.summary(verbose, url)
466449
pp summary
450+
exit 0
467451
end
468452
end
469453

lib/vmfloaty/utils.rb

+21
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,25 @@ def self.get_all_token_vms(verbose, url, token)
9292
running_vms = vms['running']
9393
running_vms
9494
end
95+
96+
def self.prettyprint_status(status, message, pools, verbose)
97+
pools.select! {|name,pool| pool['ready'] < pool['max']} if ! verbose
98+
99+
width = pools.keys.map(&:length).max
100+
pools.each do |name,pool|
101+
begin
102+
max = pool['max']
103+
ready = pool['ready']
104+
pending = pool['pending']
105+
missing = max - ready - pending
106+
char = 'o'
107+
puts "#{name.ljust(width)} #{(char*ready).green}#{(char*pending).yellow}#{(char*missing).red}"
108+
rescue => e
109+
puts "#{name.ljust(width)} #{e.red}"
110+
end
111+
end
112+
113+
puts
114+
puts message.colorize(status['status']['ok'] ? :default : :red)
115+
end
95116
end

lib/vmfloaty/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
class Version
3-
@version = '0.7.4'
3+
@version = '0.7.5'
44

55
def self.get
66
@version

vmfloaty.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = 'vmfloaty'
3-
s.version = '0.7.4'
3+
s.version = '0.7.5'
44
s.authors = ['Brian Cain']
55
s.email = ['[email protected]']
66
s.license = 'Apache'

0 commit comments

Comments
 (0)