Sha256: c26e1c6317bf2adeb5fda295e4c8cfd8f8d7d854f5a3d2c4545b6ce9601eb08c

Contents?: true

Size: 1.94 KB

Versions: 10

Compression:

Stored size: 1.94 KB

Contents

module Heirloom
  module CLI
    class List

      include Heirloom::CLI::Shared

      def initialize
        @opts = read_options
        @logger = HeirloomLogger.new :log_level => @opts[:level]
        @config = load_config :logger => @logger,
                              :opts   => @opts

        ensure_valid_options :provided => @opts,
                             :required => [:name],
                             :config   => @config
        ensure_valid_region :region => @opts[:metadata_region],
                            :config => @config
        ensure_domain_exists :name => @opts[:name], :config => @config

        @archive = Archive.new :name   => @opts[:name],
                               :config => @config
      end
      
      def list(count = @opts[:count])
        @logger.debug "#{@archive.count} archives found."
        jj @archive.list(count)
      end

      private

      def read_options
        Trollop::options do
          version Heirloom::VERSION
          banner <<-EOS

List Heirloom IDs.

Usage:

heirloom list -n NAME

EOS
          opt :count, "Number of IDs to return.", :type    => :integer,
                                                  :default => 10
          opt :help, "Display Help"
          opt :level, "Log level [debug|info|warn|error].", :type    => :string,
                                                            :default => 'info'
          opt :metadata_region, "AWS region to store Heirloom metadata.", :type    => :string,   
                                                                          :default => 'us-west-1'
          opt :name, "Name of Heirloom.", :type => :string
          opt :aws_access_key, "AWS Access Key ID", :type => :string, 
                                                    :short => :none
          opt :aws_secret_key, "AWS Secret Access Key", :type => :string, 
                                                        :short => :none
        end
      end

    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
heirloom-0.7.4 lib/heirloom/cli/list.rb
heirloom-0.7.3 lib/heirloom/cli/list.rb
heirloom-0.7.3rc2 lib/heirloom/cli/list.rb
heirloom-0.7.3rc1 lib/heirloom/cli/list.rb
heirloom-0.7.2 lib/heirloom/cli/list.rb
heirloom-0.7.2rc2 lib/heirloom/cli/list.rb
heirloom-0.7.2rc1 lib/heirloom/cli/list.rb
heirloom-0.7.1 lib/heirloom/cli/list.rb
heirloom-0.7.0 lib/heirloom/cli/list.rb
heirloom-0.7.0rc1 lib/heirloom/cli/list.rb