Sha256: 4c5f65e1dd7ffcc6ec7e5498374a7ae7cffb1747f379c8f5abf0678d220ba1ea

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

module Heirloom
  module CLI
    class Download

      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 => [:base_prefix, :name, :id, :output],
                             :config   => @config

        @archive = Archive.new :name   => @opts[:name],
                               :id     => @opts[:id],
                               :config => @config
      end
      
      def download
        @archive.download :output      => @opts[:output],
                          :region      => @opts[:region],
                          :base_prefix => @opts[:base_prefix]
      end

      private

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

Download an archive.

Usage:

heirloom download -n NAME -i ID -r REGION -o OUTPUT_FILE

EOS
          opt :help, "Display Help"
          opt :base_prefix, "Base prefix of the archive to download.", :type => :string
          opt :id, "ID of the archive to download.", :type => :string
          opt :key, "AWS Access Key ID", :type => :string
          opt :name, "Name of archive.", :type => :string
          opt :level, "Log level [debug|info|warn|error].", :type    => :string,
                                                            :default => 'info'
          opt :output, "Location to download archive.", :type => :string
          opt :region, "Region to download archive.", :type    => :string,
                                                      :default => 'us-west-1'
          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.5.0rc1 lib/heirloom/cli/download.rb