File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -899,4 +899,25 @@ describe "OptionParser with summary_width and summary_indent" do
899899 parser.summary_width = -10
900900 end
901901 end
902+
903+ it " formats subcommand help with custom summary_indent" do
904+ help = nil
905+ OptionParser .parse(%w(subcommand --help) ) do |opts |
906+ opts.summary_indent = " ||"
907+ opts.banner = " Usage: foo"
908+
909+ opts.on(" subcommand" , " Subcommand description" ) do
910+ opts.banner = " Usage: foo subcommand"
911+ opts.on(" --local" , " Local flag" ) { }
912+ end
913+ opts.on(" other" , " Other subcommand" ) { }
914+ opts.on(" --help" , " Help" ) { help = opts.to_s }
915+ end
916+
917+ help.should eq <<-USAGE
918+ Usage: foo subcommand
919+ ||--help Help
920+ ||--local Local flag
921+ USAGE
922+ end
902923end
Original file line number Diff line number Diff line change @@ -493,7 +493,7 @@ class OptionParser
493493 # subcommands since they are no longer valid.
494494 unless flag.starts_with?('-' )
495495 @handlers .select! { |k , _ | k.starts_with?('-' ) }
496- @flags .select!(& .starts_with?(" -" ))
496+ @flags .select!(& .starts_with?(" #{ summary_indent } -" ))
497497 end
498498
499499 handler.block.call(value || " " )
You can’t perform that action at this time.
0 commit comments