lib/main/usage.rb in main-0.0.2 vs lib/main/usage.rb in main-2.0.0

- old
+ new

@@ -24,32 +24,46 @@ self[key] = nil end alias_method 'delete', 'delete_at' def self.default_synopsis main + # build up synopsis s = "#{ main.name }" + # mode info + if main.mode_name != 'main' + s << " #{ main.fully_qualified_mode.join ' ' }" + end + + unless main.modes.empty? + modes = main.modes.keys.join('|') + s << " (#{ modes })" + end + + # argument info main.parameters.each do |p| if p.type == :argument if p.required? s << " #{ p.name }" else s << " [#{ p.name }]" end end end + # keyword info main.parameters.each do |p| if p.type == :keyword if p.required? s << " #{ p.name }=#{ p.name }" else s << " [#{ p.name }=#{ p.name }]" end end end + # option info n = 0 main.parameters.each do |p| if p.type == :option if p.required? case p.argument @@ -101,15 +115,19 @@ parameters = arguments + keywords + options + environment s = parameters.map do |p| ps = '' - ps << Util.columnize("* #{ p.synopsis }", :indent => 2, :width => 78) - ps << "\n" + ps << Util.columnize("#{ p.synopsis }", :indent => 2, :width => 78) + #ps << Util.columnize("* #{ p.synopsis }", :indent => 2, :width => 78) + #ps << "\n" if p.description? - ps << Util.columnize(p.description, :indent => 6, :width => 78) 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" ps end.join("\n") usage['parameters'] = s # author