Sha256: b08b03d589341217f9310de037d06d4ec0490789c6babc01b78b3a18b18a746c

Contents?: true

Size: 1.94 KB

Versions: 3

Compression:

Stored size: 1.94 KB

Contents

require 'r10k/cli'
require 'r10k/puppetfile'

require 'cri'

module R10K::CLI
  module Puppetfile
    def self.command
      @cmd ||= Cri::Command.define do
        name    'puppetfile'
        usage   'puppetfile <subcommand>'
        summary 'Perform operations on a Puppetfile'

        run do |opts, args, cmd|
          puts cmd.help
          exit 0
        end
      end
    end

    module Install
      def self.command
        @cmd ||= Cri::Command.define do
          name    'install'
          usage   'install'
          summary 'Install all modules from a Puppetfile'

          run do |opts, args, cmd|
            puppetfile_root = Dir.getwd
            puppetfile_path = ENV['PUPPETFILE_DIR']
            puppetfile      = ENV['PUPPETFILE']

            puppetfile = R10K::Puppetfile.new(puppetfile_root, puppetfile_path, puppetfile)

            runner = R10K::TaskRunner.new(opts)
            task   = R10K::Task::Puppetfile::Sync.new(puppetfile)
            runner.append_task task

            runner.run

            exit runner.exit_value
          end
        end
      end
    end
    self.command.add_command(Install.command)

    module Purge
      def self.command
        @cmd ||= Cri::Command.define do
          name  'purge'
          usage 'purge'
          summary 'Purge unmanaged modules from a Puppetfile managed directory'

          run do |opts, args, cmd|
            puppetfile_root = Dir.getwd
            puppetfile_path = ENV['PUPPETFILE_DIR']
            puppetfile      = ENV['PUPPETFILE']

            puppetfile = R10K::Puppetfile.new(puppetfile_root, puppetfile_path, puppetfile)

            runner = R10K::TaskRunner.new(opts)
            task   = R10K::Task::Puppetfile::Purge.new(puppetfile)
            runner.append_task task

            runner.run

            exit runner.exit_value
          end
        end
      end
    end
    self.command.add_command(Purge.command)
  end
  self.command.add_command(Puppetfile.command)
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
r10k-1.0.0rc3 lib/r10k/cli/puppetfile.rb
r10k-1.0.0rc2 lib/r10k/cli/puppetfile.rb
r10k-1.0.0rc1 lib/r10k/cli/puppetfile.rb