lib/kontena/cli/plugins/install_command.rb in kontena-cli-0.16.0.pre5 vs lib/kontena/cli/plugins/install_command.rb in kontena-cli-0.16.0.pre6
- old
+ new
@@ -1,22 +1,29 @@
require 'open3'
module Kontena::Cli::Plugins
class InstallCommand < Kontena::Command
include Kontena::Util
+ include Kontena::Cli::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 execute
install_plugin(name)
end
def install_plugin(name)
plugin = "kontena-plugin-#{name}"
gem_bin = which('gem')
- install_command = "#{gem_bin} install --no-ri --no-doc #{plugin}"
+ install_options = ['--no-ri', '--no-doc']
+ install_options << "--version #{version}" if version
+ install_options << "--pre" if pre?
+ install_command = "#{gem_bin} install #{install_options.join(' ')} #{plugin}"
success = false
- spinner "Installing plugin #{name.colorize(:cyan)}" do
+ spinner "installing plugin #{name.colorize(:cyan)}" do
stdout, stderr, status = Open3.capture3(install_command)
unless stderr.empty?
raise stderr
end
end