added dynamic resizing of description for flag & the like

This commit is contained in:
Tristan Ancelet
2026-08-12 12:56:59 -05:00
parent e90d89689c
commit f889aae5e1
+6 -4
View File
@@ -3,13 +3,15 @@ Command: <%= @name %>
Description: <%= @description %> Description: <%= @description %>
<%- end -%> <%- end -%>
<%- len = @flags.map{|f| f.short.nil? ? f.long.size : "#{f.short},#{f.long}".size}.max + 5 -%>
Flags: Flags:
--------------------------------------------------------------- ---------------------------------------------------------------
<%- @flags.each do |flag| -%> <%- @flags.each do |flag| -%>
<%- unless flag.short.nil? -%> <%- unless flag.short.nil? -%>
<%= "%-30s %s" % ["#{flag.short.not_nil!.strip},#{flag.long.strip}", flag.description.strip] %> <%= "%-#{len}s %s" % ["#{flag.short.not_nil!.strip},#{flag.long.strip}", flag.description.strip] %>
<%- else -%> <%- else -%>
<%= "%-30s %s" % [flag.long.strip, flag.description.strip] %> <%= "%-#{len}s %s" % [flag.long.strip, flag.description.strip] %>
<%- end -%> <%- end -%>
<%- end -%> <%- end -%>
@@ -17,7 +19,7 @@ Flags:
Other Commands Other Commands
--------------------------------------------------------------- ---------------------------------------------------------------
<%- @commands.each do |command| -%> <%- @commands.each do |command| -%>
<%= "%-30s %s" % [ command.name, command.description ] %> <%= "%-#{len}s %s" % [ command.name, command.description ] %>
<%- end -%> <%- end -%>
<%- end -%> <%- end -%>
@@ -25,7 +27,7 @@ Other Commands
SubCommands of <%= @name %>: SubCommands of <%= @name %>:
--------------------------------------------------------------- ---------------------------------------------------------------
<%- subcommands.each do |cmd| -%> <%- subcommands.each do |cmd| -%>
<%= "%-30s %s" % [cmd.name, cmd.description] %> <%= "%-#{len}s %s" % [cmd.name, cmd.description] %>
<%- end -%> <%- end -%>
<%- cmds = subcommands.select{|c| ! c.examples.nil? } -%> <%- cmds = subcommands.select{|c| ! c.examples.nil? } -%>