Class: Azuki::Command::Plugins

Inherits:
Base
  • Object
show all
Defined in:
lib/azuki/command/plugins.rb

Overview

manage plugins to the azuki gem

Instance Attribute Summary

Attributes inherited from Base

#args, #options

Instance Method Summary collapse

Methods inherited from Base

#api, #app, #azuki, #initialize, namespace

Methods included from Helpers

#action, #ask, #confirm, #confirm_billing, #confirm_command, #create_git_remote, #deprecate, #display, #display_header, #display_object, #display_row, #display_table, #error, error_with_failure, error_with_failure=, extended, extended_into, #fail, #format_bytes, #format_date, #format_error, #format_with_bang, #get_terminal_environment, #git, #has_git?, #home_directory, #hprint, #hputs, included, included_into, #json_decode, #json_encode, #launchy, #line_formatter, #longest, #output_with_bang, #quantify, #redisplay, #retry_on_exception, #run_command, #running_on_a_mac?, #running_on_windows?, #set_buffer, #shell, #spinner, #status, #string_distance, #styled_array, #styled_error, #styled_hash, #styled_header, #suggestion, #time_ago, #truncate, #with_tty

Constructor Details

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

Instance Method Details

#indexObject

plugins

list installed plugins

Example:

$ azuki plugins

Installed Plugins

azuki-accounts



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/azuki/command/plugins.rb', line 18

def index
  validate_arguments!

  plugins = ::Azuki::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 URL

install a plugin

Example:

$ azuki plugins:install github.com/ddollar/azuki-accounts.git Installing azuki-accounts… done



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/azuki/command/plugins.rb', line 40

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

  action("Installing #{plugin.name}") do
    if plugin.install
      unless Azuki::Plugin.load_plugin(plugin.name)
        plugin.uninstall
        exit(1)
      end
    else
      error("Could not install #{plugin.name}. Please check the URL and try again.")
    end
  end
end

#uninstallObject

plugins:uninstall PLUGIN

uninstall a plugin

Example:

$ azuki plugins:uninstall azuki-accounts Uninstalling azuki-accounts… done



65
66
67
68
69
70
71
72
# File 'lib/azuki/command/plugins.rb', line 65

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

  action("Uninstalling #{plugin.name}") do
    plugin.uninstall
  end
end

#updateObject

plugins:update [PLUGIN]

updates all plugins or a single plugin by name

Example:

$ azuki plugins:update Updating azuki-accounts… done

$ azuki plugins:update azuki-accounts Updating azuki-accounts… done



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/azuki/command/plugins.rb', line 86

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

  plugins.each do |plugin|
    begin
      action("Updating #{plugin}") do
        begin
          Azuki::Plugin.new(plugin).update
        rescue Azuki::Plugin::ErrorUpdatingSymlinkPlugin
          status "skipped symlink"
        end
      end
    rescue SystemExit
      # ignore so that other plugins still update
    end
  end
end