class Mixlib::Install::Cli

Public Class Methods

exit_on_failure?() click to toggle source
# File lib/mixlib/install/cli.rb, line 23
def self.exit_on_failure?
  true
end

Public Instance Methods

download(product_name) click to toggle source
# File lib/mixlib/install/cli.rb, line 69
def download(product_name)
  # Set minimum options
  mixlib_install_options = {
    channel: options[:channel].to_sym,
    product_name: product_name,
    product_version: options[:version],
    platform_version_compatibility_mode: options[:platform_version_compat],
    architecture: options[:architecture],
  }.tap do |opt|
    opt[:platform] = options[:platform] if options[:platform]
    opt[:platform_version] = options[:platform_version] if options[:platform_version]
  end

  # auto detect platform options if not configured
  if options[:platform].nil? && options[:platform_version].nil?
    mixlib_install_options.merge!(Mixlib::Install.detect_platform)
  end

  installer = Mixlib::Install.new(mixlib_install_options)

  begin
    artifact = installer.artifact_info
  rescue Mixlib::Install::Backend::ArtifactsNotFound => e
    abort e.message
  end

  if options[:url]
    say artifact.url
  else
    say "Starting download #{artifact.url}"
    file = installer.download_artifact(options[:directory])
    say "Download saved to #{file}"
  end

  say JSON.pretty_generate(artifact.to_hash) if options[:attributes]
end
install_script() click to toggle source
# File lib/mixlib/install/cli.rb, line 117
def install_script
  context = {}
  context[:base_url] = options[:endpoint] if options[:endpoint]
  script = eval("Mixlib::Install.install_#{options[:type]}(context)")
  if options[:file]
    File.open(options[:file], "w") { |io| io.write(script) }
    say "Script written to #{options[:file]}"
  else
    say script
  end
end
list_versions(product_name, channel) click to toggle source
# File lib/mixlib/install/cli.rb, line 34
def list_versions(product_name, channel)
  say Mixlib::Install.available_versions(product_name, channel).join("\n")
end
version() click to toggle source
# File lib/mixlib/install/cli.rb, line 28
def version
  require_relative "version"
  say Mixlib::Install::VERSION
end