2
require 'puppet/application'
11
return "" unless txt && !txt.empty?
12
work = (opts[:scrub] ? scrub(txt) : txt)
13
indent = (opts[:indent] ? opts[:indent] : 0)
14
textLen = @width - indent
15
patt = Regexp.new("^(.{0,#{textLen}})[ \n]")
20
while work.length > textLen
23
work.slice!(0, $&.length)
25
res << work.slice!(0, textLen)
28
res << work if work.length.nonzero?
29
return prefix + res.join("\n" + prefix)
32
def header(txt, sep = "-")
33
"\n#{txt}\n" + sep * txt.size
39
# For text with no carriage returns, there's nothing to do.
45
# If we can match an indentation, then just remove that same level of
46
# indent from every line.
49
return text.gsub(/^#{indent}/,'')
60
@format = Formatter.new(76)
63
Puppet::Type.eachtype { |type|
64
next if type.name == :component
65
@types[type.name] = type
70
puts "These are the types known to puppet:\n"
71
@types.keys.sort { |a, b|
75
s = type.doc.gsub(/\s+/, " ")
78
s = ".. no documentation .."
84
printf "%-15s - %s\n", name, s
88
def format_type(name, opts)
90
unless @types.has_key?(name)
91
puts "Unknown type #{name}"
95
puts @format.header(name.to_s, "=")
96
puts @format.wrap(type.doc, :indent => 0, :scrub => true) + "\n\n"
98
puts @format.header("Parameters")
100
format_attrs(type, [:property, :param])
102
list_attrs(type, [:property, :param])
106
puts @format.header("Meta Parameters")
108
format_attrs(type, [:meta])
110
list_attrs(type, [:meta])
114
if type.providers.size > 0
115
puts @format.header("Providers")
117
format_providers(type)
124
# List details about attributes
125
def format_attrs(type, attrs)
127
type.allattrs.each do |name|
128
kind = type.attrtype(name)
129
if attrs.include?(kind) && name != :provider
130
docs[name] = type.attrclass(name).doc
135
a[0].to_s <=> b[0].to_s
137
print "\n- **%s**" % name
138
if type.namevar == name and name != :name
143
puts @format.wrap(doc, :indent => 4, :scrub => true)
147
# List the names of attributes
148
def list_attrs(type, attrs)
150
type.allattrs.each do |name|
151
kind = type.attrtype(name)
152
if attrs.include?(kind) && name != :provider
156
puts @format.wrap(params.sort.join(", "), :indent => 4)
159
def format_providers(type)
160
type.providers.sort { |a,b|
163
puts "\n- **%s**" % prov
164
puts @format.wrap(type.provider(prov).doc,
165
:indent => 4, :scrub => true)
169
def list_providers(type)
170
list = type.providers.sort { |a,b|
173
puts @format.wrap(list, :indent => 4)
178
Puppet::Application.new(:pi,"#{$0} [options] [type]") do
180
should_not_parse_config
182
option("--short", "-s", "Only list parameters without detail") do |arg|
183
options[:parameters] = false
186
option("--providers","-p")
187
option("--list", "-l")
188
option("--meta","-m")
191
options[:parameters] = true
200
options[:types].each { |name| doc.format_type(name, options) }
205
options[:types] = ARGV.dup
206
unless options[:list] || options[:types].size > 0
209
if options[:list] && options[:types].size > 0
210
$stderr.puts "Warning: ignoring types when listing all types"