class Clamp::Help::Builder
A builder for auto-generated help.
Constants
- DETAIL_FORMAT
Attributes
Public Class Methods
Public Instance Methods
Source
# File lib/clamp/help.rb, line 93 def add_description(description) return unless description line line description.gsub(/^/, " ") end
Source
# File lib/clamp/help.rb, line 101 def add_list(heading, items) line line "#{heading}:" items.reject { |i| i.respond_to?(:hidden?) && i.hidden? }.each do |item| label, description = item.help description.each_line do |line| row(label, line) label = "" end end end
Source
# File lib/clamp/help.rb, line 86 def add_usage(invocation_path, usage_descriptions) line Clamp.message(:usage_heading) + ":" usage_descriptions.each do |usage| line " #{invocation_path} #{usage}".rstrip end end
Source
# File lib/clamp/help.rb, line 62 def string left_column_width = lines.grep(Array).map(&:first).map(&:size).max StringIO.new.tap do |out| lines.each do |line| case line when Array line[0] = line[0].ljust(left_column_width) line.unshift("") out.puts(line.join(" ")) else out.puts(line) end end end.string end