Method: Main::Usage#parameters_section

Defined in:
lib/main/usage.rb

#parameters_sectionObject



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/main/usage.rb', line 134

def parameters_section
  arguments = main.parameters.select{|p| p.type == :argument}
  keywords = main.parameters.select{|p| p.type == :keyword}
  options = main.parameters.select{|p| p.type == :option}
  environment = main.parameters.select{|p| p.type == :environment}

  help, nothelp = options.partition{|p| p.name == 'help'}
  options = nothelp + help

  parameters = arguments + keywords + options + environment

  parameters.map do |p|
    ps = ''
    ps << Util.columnize("#{ p.synopsis }", :indent => 2, :width => 78)
    #ps << Util.columnize("* #{ p.synopsis }", :indent => 2, :width => 78)
    #ps << "\n"
    if p.description?
      ps << "\n"
      ps << Util.columnize("#{ p.description }", :indent => 6, :width => 78)
      #ps << Util.columnize(p.description, :indent => 6, :width => 78)
      #ps << "\n"
    end
    #ps << "\n"
    unless(p.examples.nil? or p.examples.empty?)
      p.examples.each do |example|
        ps << "\n"
        ps << Util.columnize("#{ example }", :indent => 8, :width => 78)
      end
    end
    ps
  end.join("\n")
end