lib/chronicle/etl/cli/plugins.rb in chronicle-etl-0.4.2 vs lib/chronicle/etl/cli/plugins.rb in chronicle-etl-0.4.3
- old
+ new
@@ -1,42 +1,42 @@
# frozen_string_literal: true
require "tty-prompt"
require "tty-spinner"
-
module Chronicle
module ETL
module CLI
# CLI commands for working with ETL plugins
class Plugins < SubcommandBase
default_task 'list'
namespace :plugins
desc "install", "Install a plugin"
- def install(name)
- spinner = TTY::Spinner.new("[:spinner] Installing plugin #{name}...", format: :dots_2)
+ def install(*plugins)
+ cli_fail(message: "Please specify a plugin to install") unless plugins.any?
+
+ spinner = TTY::Spinner.new("[:spinner] Installing #{plugins.join(", ")}...", format: :dots_2)
spinner.auto_spin
- Chronicle::ETL::Registry::PluginRegistry.install(name)
+ plugins.each do |plugin|
+ spinner.update(title: "Installing #{plugin}")
+ Chronicle::ETL::Registry::PluginRegistry.install(plugin)
+ rescue Chronicle::ETL::PluginError => e
+ spinner.error("Error".red)
+ cli_fail(message: "Plugin '#{plugin}' could not be installed", exception: e)
+ end
spinner.success("(#{'successful'.green})")
- rescue Chronicle::ETL::PluginError => e
- spinner.error("Error".red)
- Chronicle::ETL::Logger.debug(e.full_message)
- Chronicle::ETL::Logger.fatal("Plugin '#{name}' could not be installed".red)
- exit 1
end
desc "uninstall", "Unintall a plugin"
def uninstall(name)
spinner = TTY::Spinner.new("[:spinner] Uninstalling plugin #{name}...", format: :dots_2)
spinner.auto_spin
Chronicle::ETL::Registry::PluginRegistry.uninstall(name)
spinner.success("(#{'successful'.green})")
rescue Chronicle::ETL::PluginError => e
spinner.error("Error".red)
- Chronicle::ETL::Logger.debug(e.full_message)
- Chronicle::ETL::Logger.fatal("Plugin '#{name}' could not be uninstalled (was it installed?)".red)
- exit 1
+ cli_fail(message: "Plugin '#{name}' could not be uninstalled (was it installed?)", exception: e)
end
desc "list", "Lists available plugins"
# Display all available plugins that chronicle-etl has access to
def list