File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,7 @@ def cmd_help_tabs(str, words)
232
232
#
233
233
# Return a pretty, user-readable table of commands provided by this
234
234
# dispatcher.
235
+ # The command column width can be modified by passing in :command_width.
235
236
#
236
237
def help_to_s ( opts = { } )
237
238
# If this dispatcher has no commands, we can't do anything useful.
@@ -250,7 +251,7 @@ def help_to_s(opts={})
250
251
{
251
252
'Command' =>
252
253
{
253
- 'Width' => 12
254
+ 'Width' => opts [ :command_width ]
254
255
}
255
256
} )
256
257
@@ -656,8 +657,10 @@ def current_dispatcher
656
657
def help_to_s ( opts = { } )
657
658
str = ''
658
659
660
+ max_command_length = dispatcher_stack . flat_map { |dispatcher | dispatcher . commands . to_a } . map { |( name , _description ) | name . length } . max
661
+
659
662
dispatcher_stack . reverse . each { |dispatcher |
660
- str << dispatcher . help_to_s
663
+ str << dispatcher . help_to_s ( opts . merge ( { command_width : [ max_command_length , 12 ] . max } ) )
661
664
}
662
665
663
666
return str
You can’t perform that action at this time.
0 commit comments