2014-01-05 16:42:34 +00:00
|
|
|
require "vagrant/plugin/manager"
|
|
|
|
|
2013-02-03 07:52:34 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module CommandPlugin
|
|
|
|
module Action
|
2013-02-03 07:59:48 +00:00
|
|
|
# This middleware lists all the installed plugins.
|
|
|
|
#
|
|
|
|
# This is a bit more complicated than simply listing installed
|
|
|
|
# gems or what is in the state file as installed. Instead, this
|
|
|
|
# actually compares installed gems with what the state file claims
|
|
|
|
# is installed, and outputs the appropriate truly installed
|
|
|
|
# plugins.
|
2013-02-03 07:52:34 +00:00
|
|
|
class ListPlugins
|
|
|
|
def initialize(app, env)
|
|
|
|
@app = app
|
|
|
|
end
|
|
|
|
|
|
|
|
def call(env)
|
2014-01-06 05:16:41 +00:00
|
|
|
manager = Vagrant::Plugin::Manager.instance
|
|
|
|
plugins = manager.installed_plugins
|
|
|
|
specs = manager.installed_specs
|
2013-02-03 20:59:32 +00:00
|
|
|
|
|
|
|
# Output!
|
2014-01-06 04:50:25 +00:00
|
|
|
if specs.empty?
|
2013-02-03 21:13:22 +00:00
|
|
|
env[:ui].info(I18n.t("vagrant.commands.plugin.no_plugins"))
|
2014-01-06 05:16:41 +00:00
|
|
|
return @app.call(env)
|
2014-01-06 04:50:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
specs.each do |spec|
|
2014-03-03 22:57:42 +00:00
|
|
|
# Grab the plugin.
|
2014-01-06 05:16:41 +00:00
|
|
|
plugin = plugins[spec.name]
|
2014-03-03 22:57:42 +00:00
|
|
|
|
|
|
|
system = ""
|
|
|
|
system = ", system" if plugin && plugin["system"]
|
|
|
|
env[:ui].info "#{spec.name} (#{spec.version}#{system})"
|
2014-01-06 05:16:41 +00:00
|
|
|
|
|
|
|
if plugin["gem_version"] && plugin["gem_version"] != ""
|
|
|
|
env[:ui].info(I18n.t(
|
|
|
|
"vagrant.commands.plugin.plugin_version",
|
|
|
|
version: plugin["gem_version"]))
|
|
|
|
end
|
|
|
|
|
|
|
|
if plugin["require"] && plugin["require"] != ""
|
|
|
|
env[:ui].info(I18n.t(
|
|
|
|
"vagrant.commands.plugin.plugin_require",
|
|
|
|
require: plugin["require"]))
|
|
|
|
end
|
2013-02-03 07:52:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@app.call(env)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|