class OpzWorks::Commands::CMD

Public Class Methods

banner() click to toggle source
run() click to toggle source
# File lib/opzworks/commands/cmd.rb, line 15
      def self.run
        options = Trollop.options do
          banner <<-EOS.unindent
            #{CMD.banner}

              opzworks cmd [--list-stacks]

            Options:
          EOS
          opt :'list-stacks', 'List all our stacks', default: false
        end

        config = OpzWorks.config
        client = Aws::OpsWorks::Client.new(region: config.aws_region, profile: config.aws_profile)

        if options[:'list-stacks']
          list = []
          response = client.describe_stacks
          response[:stacks].each { |stack| list << stack[:name] }

          puts list.sort
        else
          puts 'No options specified'.foreground(:yellow)
        end
      end