Sha256: 9ebc0ff9df247707f9bbc64b9dec22b8845705699500959447fe1cbf77378d65

Contents?: true

Size: 1.25 KB

Versions: 34

Compression:

Stored size: 1.25 KB

Contents

require 'kontena/plugin_manager'

module Kontena::Cli::Plugins
  class InstallCommand < Kontena::Command
    include Kontena::Util
    include Kontena::Cli::Common
    include Kontena::PluginManager::Common

    parameter 'NAME', 'Plugin name'

    option ['-v', '--version'], 'VERSION', 'Specify version of plugin to install'
    option '--pre', :flag, 'Allow pre-release of a plugin to be installed', default: false

    def installer
      Kontena::PluginManager::Installer.new(name, pre: pre?, version: version)
    end

    def execute
      if installed?(name)
        installed = spinner "Upgrading plugin #{pastel.cyan(name)}" do
          installer.upgrade
        end

        spinner "Running cleanup" do |spin|
          Kontena::PluginManager::Cleaner.new(name).cleanup
        end
      else
        installed = spinner "Installing plugin #{pastel.cyan(name)}" do
          installer.install
        end
      end

      Array(installed).each do |gem|
        if gem.name.start_with?('kontena-plugin-')
          puts Kontena.pastel.green("Installed plugin #{gem.name.sub('kontena-plugin-', '')} version #{gem.version}")
        else
          puts Kontena.pastel.cyan("Installed dependency #{gem.name} version #{gem.version}")
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
krates-1.7.11 lib/kontena/cli/plugins/install_command.rb
krates-1.7.10 lib/kontena/cli/plugins/install_command.rb
krates-1.7.9 lib/kontena/cli/plugins/install_command.rb
krates-1.7.8 lib/kontena/cli/plugins/install_command.rb
krates-1.7.7 lib/kontena/cli/plugins/install_command.rb
krates-1.7.6 lib/kontena/cli/plugins/install_command.rb
krates-1.7.5 lib/kontena/cli/plugins/install_command.rb
krates-1.7.4 lib/kontena/cli/plugins/install_command.rb
krates-1.7.3 lib/kontena/cli/plugins/install_command.rb
krates-1.7.2 lib/kontena/cli/plugins/install_command.rb
krates-1.7.1 lib/kontena/cli/plugins/install_command.rb
krates-1.7.0 lib/kontena/cli/plugins/install_command.rb
krates-1.6.9 lib/kontena/cli/plugins/install_command.rb
krates-1.6.8 lib/kontena/cli/plugins/install_command.rb
krates-1.6.7 lib/kontena/cli/plugins/install_command.rb
krates-1.6.6 lib/kontena/cli/plugins/install_command.rb
krates-1.6.5 lib/kontena/cli/plugins/install_command.rb
krates-1.6.4 lib/kontena/cli/plugins/install_command.rb
krates-1.6.3 lib/kontena/cli/plugins/install_command.rb
krates-1.6.2 lib/kontena/cli/plugins/install_command.rb