Class: Puppetfiler::CLI

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

Instance Method Summary collapse

Instance Method Details

#checkObject



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
63
64
65
66
67
68
69
70
71
# File 'lib/puppetfiler/cli.rb', line 38

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

    titles = updates.first[1].keys

    maxlen_name = 0
    maxlen_val  = titles.map { |t| t.length }.max

    updates.each do |name, hash|
        maxlen_name = name.length if name.length > maxlen_name
        hash.each do |k, v|
            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  " * titles.count )

    puts sprintf(format, 'module', *titles)

    updates.each do |name, hash|
        puts sprintf(format, name, *hash.values)
    end
end

#fixtureObject



75
76
77
78
79
80
81
82
83
84
# File 'lib/puppetfiler/cli.rb', line 75

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



87
88
89
# File 'lib/puppetfiler/cli.rb', line 87

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