Class: MediaWikiVagrant::Roles::Info
Class Method Summary
collapse
Instance Method Summary
collapse
#initialize, #interactive_out?
Class Method Details
12
13
14
|
# File 'lib/mediawiki-vagrant/roles/info.rb', line 12
def self.synopsis
'get information about a mediawiki-vagrant role'
end
|
Instance Method Details
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
|
# File 'lib/mediawiki-vagrant/roles/info.rb', line 16
def execute
opts = OptionParser.new do |o|
o.banner = 'Usage: vagrant roles info [<role> ...]'
o.separator ''
o.separator ' Describe a mediawiki-vagrant role.'
o.separator ''
end
argv = parse_options(opts)
return unless argv
if argv.any?
roles = argv.map(&:downcase)
invalid_roles = roles - @mwv.roles_available
if invalid_roles.any?
invalid_roles.each { |role| @env.ui.error "'#{role}' is not a valid role." }
return 1
end
else
roles = @mwv.roles_available
end
rd = RDoc::Markup::ToAnsi.new
settings = @mwv.load_settings
roles.each do |role|
doc = @mwv.role_docstring(role)
@env.ui.info rd.convert(doc) if doc
changes = @mwv.load_settings(@mwv.roles_enabled + [role]) - settings
next unless changes.any?
@env.ui.warn 'Enabling this role will adjust the following settings:'
changes.each do |setting, change|
cur, new = *change.map { |v| setting_display_value(v) }
@env.ui.info ''
@env.ui.info setting.description unless setting.description.nil?
@env.ui.info "#{setting.name}: #{cur} -> ", new_line: false
@env.ui.info "#{new}", bold: true
end
end
0
end
|