Sha256: bc40a6698326d943370c84048820f88c8d4f4d77845000bf9e4511a90e13ff2d

Contents?: true

Size: 1.09 KB

Versions: 10

Compression:

Stored size: 1.09 KB

Contents

require 'r10k/cli/module'
require 'r10k/deployment'
require 'cri'

module R10K::CLI::Module
  module List
    def self.command
      @cmd ||= Cri::Command.define do
        name  'list'
        usage 'list'
        summary 'List modules that are instantiated in environments'

        run do |opts, args, cmd|
          deployment = R10K::Deployment.instance
          env_list   = deployment.environments

          update_cache = (defined? opts[:update]) ? (opts[:update] == 'true') : false

          if opts[:environment]
            environments = env_list.select {|env| env.name == opts[:environment]}
          else
            environments = env_list
          end

          printree = {}

          environments.each do |env|
            module_names = env.modules.map(&:name)

            printree[env.name] = module_names
          end

          printree.each_pair do |env_name, mod_list|
            puts "  - #{env_name}"
            mod_list.each do |mod|
              puts "      #{mod}"
            end
          end
        end
      end
    end
  end
  self.command.add_command(List.command)
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
r10k-0.0.9 lib/r10k/cli/module/list.rb
r10k-0.0.8 lib/r10k/cli/module/list.rb
r10k-0.0.7 lib/r10k/cli/module/list.rb
r10k-0.0.6 lib/r10k/cli/module/list.rb
r10k-0.0.5 lib/r10k/cli/module/list.rb
r10k-0.0.4 lib/r10k/cli/module/list.rb
r10k-0.0.3 lib/r10k/cli/module/list.rb
r10k-0.0.2 lib/r10k/cli/module/list.rb
r10k-0.0.1 lib/r10k/cli/module/list.rb
r10k-0.0.1rc1 lib/r10k/cli/module/list.rb