Sha256: b867808c95498da3fb02d7055ed2515f686bc4cead3b4db208df8b93f00e1c93

Contents?: true

Size: 858 Bytes

Versions: 2

Compression:

Stored size: 858 Bytes

Contents

require "vmc/cli/app/base"
require "pp"

module VMC::App
  class Download < Base
    desc "Download Application"
    group :apps, :manage
    input :app, :desc => "Application name",
          :argument => true, :from_given => by_name(:app)

    def download
      app = input[:app]

      download_app(app)

    rescue CFoundry::NotFound
      fail "Invalid #{b(app.name)}"
    rescue CFoundry::FileError => e
      fail e.description
    end

    private

    def download_app(app)
      with_progress("Downloading #{c(app.name, :name)}") do
        resp = client.base.get("apps", app.name, "application", :content => "application/octet-stream")

        if not resp.nil?
          File.open("#{app.name}.zip","w") { |f| f.puts resp }
        else
          raise
        end
      end
    rescue
      err "Download failed."
      raise
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
static-1.0.1 lib/static/cli/app/download.rb
static-1.0.0 lib/static/cli/app/download.rb