29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/puppetfiler/cli.rb', line 29
def check
t = [nil, nil]
%i{puppetfile metadata}.each do |m|
if not options[m].nil?
t = [m, options[m]]
end
end
updates = Puppetfiler.check(*t)
if updates.empty?
return
end
maxlen_name = 0
maxlen_val = 0
val_count = 0
updates.each do |name, hash|
maxlen_name = name.length if name.length > maxlen_name
hash.each do |k, v|
val_count += 1
maxlen_val = k.length if k.length > maxlen_val
maxlen_val = v.length if v.length > maxlen_val
end
end
format = "% -#{maxlen_name}s " + ( "% -#{maxlen_val}s" * val_count )
puts sprintf(format, 'module', *updates.first[1].keys)
updates.each do |name, hash|
puts sprintf(format, name, *hash.values)
end
end
|