Sha256: 7f2114040c3e153d9d22f9dd10daca0bee7c56af1ffe4836317ecd8ae24b2ad4

Contents?: true

Size: 789 Bytes

Versions: 8

Compression:

Stored size: 789 Bytes

Contents

require 'open3'

module Kontena::Cli::Plugins
  class UninstallCommand < Kontena::Command
    include Kontena::Util
    include Kontena::Cli::Common

    parameter 'NAME', 'Plugin name'
    option "--force", :flag, "Force remove", default: false, attribute_name: :forced

    def execute
      require 'shellwords'
      confirm unless forced?
      uninstall_plugin(name)
    end

    def uninstall_plugin(name)
      plugin = "kontena-plugin-#{name}"
      gem_bin = which('gem')
      uninstall_command = "#{gem_bin} uninstall -q #{plugin.shellescape}"
      stderr = spinner "Uninstalling plugin #{name.colorize(:cyan)}" do |spin|
        stdout, stderr, status = Open3.capture3(uninstall_command)
        raise(RuntimeError, stderr) unless status.success?
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
kontena-cli-1.0.6 lib/kontena/cli/plugins/uninstall_command.rb
kontena-cli-1.0.6.rc1 lib/kontena/cli/plugins/uninstall_command.rb
kontena-cli-1.0.5 lib/kontena/cli/plugins/uninstall_command.rb
kontena-cli-1.0.5.rc1 lib/kontena/cli/plugins/uninstall_command.rb
kontena-cli-1.0.5.pre1 lib/kontena/cli/plugins/uninstall_command.rb
kontena-cli-1.0.4 lib/kontena/cli/plugins/uninstall_command.rb
kontena-cli-1.0.4.rc2 lib/kontena/cli/plugins/uninstall_command.rb
kontena-cli-1.0.4.rc1 lib/kontena/cli/plugins/uninstall_command.rb