| Class | Webgen::CliUtils |
| In: |
lib/webgen/cli.rb
|
| Parent: | Object |
# File lib/webgen/cli.rb, line 75
75: def self.dirinfo_output( opts, name, dirinfo )
76: ljust = 15 + opts.summary_indent.length
77: opts.separator CliUtils.section( 'Name', ljust, opts.summary_indent.length + 2 ) + "#{Color.lred( name )}"
78:
79: dirinfo.infos.sort.each do |name, value|
80: desc = CliUtils.format( value, ljust )
81: opts.separator CliUtils.section( name.capitalize, ljust, opts.summary_indent.length + 2 ) + desc.shift
82: desc.each {|line| opts.separator line}
83: end
84: opts.separator ''
85: end
# File lib/webgen/cli.rb, line 54
54: def self.format( content, indent = 0, width = 100 )
55: content ||= ''
56: return [content] if content.length + indent <= width
57: lines = []
58: while content.length + indent > width
59: index = content[0..(width-indent-1)].rindex(' ')
60: lines << (lines.empty? ? '' : ' '*indent) + content[0..index]
61: content = content[index+1..-1]
62: end
63: lines << ' '*indent + content unless content.strip.empty?
64: lines
65: end
# File lib/webgen/cli.rb, line 67
67: def self.headline( text, indent = 2 )
68: ' '*indent + "#{Color.bold( text )}"
69: end