Class: Mortar::Command::Plugins

Inherits:
Base
  • Object
show all
Includes:
Helpers
Defined in:
lib/mortar/command/plugins.rb

Overview

manage plugins to the mortar gem

Instance Attribute Summary

Attributes inherited from Base

#args, #options

Instance Method Summary collapse

Methods included from Helpers

#action, #ask, #confirm, #copy_if_not_present_at_dest, #default_host, #deprecate, #display, #display_header, #display_object, #display_row, #display_table, #display_with_indent, #download_to_file, #ensure_dir_exists, #error, error_with_failure, error_with_failure=, extended, extended_into, #format_bytes, #format_date, #format_with_bang, #full_host, #get_terminal_environment, #home_directory, #host, #hprint, #hputs, included, included_into, #installed_with_omnibus?, #json_decode, #json_encode, #line_formatter, #longest, #output_with_bang, #pending_github_team_state_message, #quantify, #redisplay, #retry_on_exception, #running_on_a_mac?, #running_on_windows?, #set_buffer, #shell, #spinner, #status, #string_distance, #styled_array, #styled_error, #styled_hash, #styled_header, #suggestion, #test_name, #ticking, #time_ago, #truncate, #warning, #with_tty, #write_to_file

Methods inherited from Base

#api, #ask_public, #config_parameters, #get_error_message_context, #git, #initialize, #initialize_embedded_project, #luigi_parameters, namespace, #pig_parameters, #project, #register_api_call, #register_do, #register_project, #spark_script_arguments, #validate_project_name, #validate_project_structure

Constructor Details

This class inherits a constructor from Mortar::Command::Base

Instance Method Details

#indexObject

plugins

list installed plugins

Example:

$ mortar plugins

Installed Plugins

watchtower



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/mortar/command/plugins.rb', line 22

def index
  validate_arguments!

  plugins = ::Mortar::Plugin.list

  if plugins.length > 0
    styled_header("Installed Plugins")
    styled_array(plugins)
  else
    display("You have no installed plugins.")
  end
end

#installObject

plugins:install GIT_URL

install a plugin

-b, –branchname BRANCHNAME # Install plugin from a specific branch.

Examples:

$ mortar plugins:install github.com/mortardata/watchtower.git Installing watchtower… done



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/mortar/command/plugins.rb', line 46

def install
  plugin = Mortar::Plugin.new(shift_argument)
  validate_arguments!

  action("Installing #{plugin.name}") do
    begin
      record_usage("plugin_install", plugin.name)
      if options[:branchname]
        plugin.install(options[:branchname])
      else
        plugin.install
      end
      Mortar::Plugin.load_plugin(plugin.name)
    rescue StandardError => e
      error e.message
    end
  end
end

#uninstallObject

plugins:uninstall PLUGIN

uninstall a plugin

Example:

$ mortar plugins:uninstall watchtower Uninstalling watchtower… done



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/mortar/command/plugins.rb', line 74

def uninstall
  plugin = Mortar::Plugin.new(shift_argument)
  validate_arguments!

  action("Uninstalling #{plugin.name}") do
    begin
      record_usage("plugin_uninstall", plugin.name)
      plugin.uninstall
    rescue Mortar::Plugin::ErrorPluginNotFound => e
      error e.message
    end
  end
end

#updateObject

plugins:update [PLUGIN]

updates all plugins or a single plugin by name

Example:

$ mortar plugins:update Updating watchtower… done

$ mortar plugins:update watchtower Updating watchtower… done



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/mortar/command/plugins.rb', line 100

def update
  plugins = if plugin = shift_argument
    [plugin]
  else
    ::Mortar::Plugin.list
  end
  validate_arguments!

  plugins.each do |plugin|
    action("Updating #{plugin}") do
      begin
        record_usage("plugin_update", plugin)
        Mortar::Plugin.new(plugin).update
      rescue Mortar::Plugin::ErrorUpdatingSymlinkPlugin
        status "skipped symlink"
      rescue StandardError => e
        status "error"
        display e.message
      end
    end
  end
end