Class: Mixlib::Install::Cli
- Inherits:
-
Thor
- Object
- Thor
- Mixlib::Install::Cli
- Includes:
- Thor::Actions
- Defined in:
- lib/mixlib/install/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #download(product_name) ⇒ Object
- #install_script ⇒ Object
- #list_versions(product_name, channel) ⇒ Object
- #version ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
23 24 25 |
# File 'lib/mixlib/install/cli.rb', line 23 def self.exit_on_failure? true end |
Instance Method Details
#download(product_name) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/mixlib/install/cli.rb', line 69 def download(product_name) # Set mininum options = { channel: [:channel].to_sym, product_name: product_name, product_version: [:version], platform_version_compatibility_mode: [:platform_version_compat], architecture: [:architecture], }.tap do |opt| opt[:platform] = [:platform] if [:platform] opt[:platform_version] = [:platform_version] if [:platform_version] end # auto detect platform options if not configured if [:platform].nil? && [:platform_version].nil? .merge!(Mixlib::Install.detect_platform) end installer = Mixlib::Install.new() begin artifact = installer.artifact_info rescue Mixlib::Install::Backend::ArtifactsNotFound => e abort e. end if [:url] say artifact.url else say "Starting download #{artifact.url}" file = installer.download_artifact([:directory]) say "Download saved to #{file}" end say JSON.pretty_generate(artifact.to_hash) if [:attributes] end |
#install_script ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/mixlib/install/cli.rb', line 117 def install_script context = {} context[:base_url] = [:endpoint] if [:endpoint] script = eval("Mixlib::Install.install_#{[:type]}(context)") if [:file] File.open([:file], "w") { |io| io.write(script) } say "Script written to #{[:file]}" else say script end end |
#list_versions(product_name, channel) ⇒ Object
34 35 36 |
# 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 |