class Puppetfiler::CLI

Public Instance Methods

check() click to toggle source
# 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
fixture() click to toggle source
# 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
version() click to toggle source
# File lib/puppetfiler/cli.rb, line 87
def version
    puts "puppetfiler v#{Puppetfiler::VERSION}"
end