6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/vagrant-plugins/command.rb', line 6
def execute
options = {}
opts = OptionParser.new do |opts|
opts.banner = "Usage: vagrant plugins"
opts.separator ""
opts.on("-a", "--all", "List builtin vagrant plugins as well.") do
options[:all] = true
end
opts.on("-H", "--no-head", "Do not print descriptive headings") do
options[:no_heads] = true
end
opts.on("-v", "--verbose", "Be verbose and display plugin features") do
options[:verbose] = true
end
end
argv = parse_options(opts)
return if !argv
ui = VagrantPlugininspection::UI::Columnized.new('plugins')
builtins = [VagrantPlugininspection::Plugin]
builtins += VagrantPlugins.constants.map { |p|
VagrantPlugininspection::Inflector::constantize("VagrantPlugins::#{p}::Plugin")
}
plugins = Vagrant.plugin("1").registered - builtins
if !options[:all] && plugins.empty?
ui.info "No plugins registered"
return 1
end
infos = (options[:all] ? Vagrant.plugin("1").registered : plugins).map { |plugin|
info = {
:name => plugin.name,
:description => plugin.description
}
info.merge!({
:hosts => !!plugin.data[:hosts],
:guests => !!plugin.data[:guests],
:provisioners => !!plugin.data[:provisioners],
:commands => plugin.data[:command] && !plugin.command.to_hash.empty?,
:action_hooks => !!plugin.data[:action_hooks],
:configs => plugin.data[:config] && !plugin.config.to_hash.empty?,
}) if options[:verbose]
info
}.compact
if options[:verbose] && !options[:no_heads]
head = <<-EOS
+- hosts
|+- guests
||+- provisioners
|||+- commands
||||+- action_hooks
|||||+- configs
EOS
ui.info head, :prefix => false
end
ui.print_columns(infos, :heads => !options[:no_heads]) do
if options[:verbose]
column :hosts, :name => '|'
column :guests, :name => '|'
column :provisioners, :name => '|'
column :commands, :name => '|'
column :action_hooks, :name => '|'
column :configs, :name => '|'
seperator "\t"
end
column :name
seperator "\t"
column :description
end
end
|