Sha256: df4a75e5f6ac56035c42f195ca88b690a81e7176273153dfebb3a6e02bffe3fd

Contents?: true

Size: 1.26 KB

Versions: 19

Compression:

Stored size: 1.26 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 #{name.colorize(:cyan)}" do
          installer.upgrade
        end

        spinner "Running cleanup" do |spin|
          Kontena::PluginManager::Cleaner.new(name).cleanup
        end
      else
        installed = spinner "Installing plugin #{name.colorize(:cyan)}" 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

19 entries across 19 versions & 1 rubygems

Version Path
kontena-cli-1.4.3 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.3.rc1 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.2 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.2.rc1 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.2.pre1 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.1 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.1.rc1 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.1.pre1 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.0 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.0.rc2 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.0.rc1 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.0.pre14 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.0.pre13 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.0.pre12 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.0.pre11 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.0.pre10 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.0.pre9 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.0.pre8 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.0.pre7 lib/kontena/cli/plugins/install_command.rb