Class: Puppetfiler::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/puppetfiler/cli.rb

Instance Method Summary collapse

Instance Method Details

#checkObject



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

#fixtureObject



66
67
68
69
70
71
72
73
74
75
# File 'lib/puppetfiler/cli.rb', line 66

def fixture
    t = [nil, nil]
    %i{puppetfile metadata}.each do |m|
        if not options[m].nil?
            t = [m, options[m]]
        end
    end

    Puppetfiler.fixture(*t, {}, options[:stdout])
end

#versionObject



78
79
80
# File 'lib/puppetfiler/cli.rb', line 78

def version
    puts "puppetfiler v#{Puppetfiler::VERSION}"
end