Sha256: dacafb4b0539323fa6cc98718f5f972f9570d353ef3bf0074a42c129c1c47278

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 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

        exit 1 unless valid_options? :provided => @opts,
                                     :required => [:name],
                                     :logger   => @logger

        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 versions of archive.

Usage:

heirloom list -n NAME

EOS
          opt :count, "Number of versions to return.", :type    => :integer,
                                                       :default => 10
          opt :help, "Display Help"
          opt :key, "AWS Access Key ID", :type => :string
          opt :level, "Log level [debug|info|warn|error].", :type    => :string,
                                                            :default => 'info'
          opt :name, "Name of archive.", :type => :string
          opt :secret, "AWS Secret Access Key", :type => :string
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heirloom-0.4.1rc1 lib/heirloom/cli/list.rb