From: "postmodern (Hal Brodigan) via ruby-core" Date: 2024-03-08T02:10:48+00:00 Subject: [ruby-core:117087] [Ruby master Bug#20328] optparse omits the option's description in the --help output if the description is an Array Issue #20328 has been updated by postmodern (Hal Brodigan). Ah ha! I suppose also adding an explicit option type class would help differentiate between option's desired value and the description lines? ```ruby opts.on('-m', '--multiline-opt', String, 'Line one', 'Line two') do |test| end ``` However, if I pass in both a `String` class, indicating the option's value type, and follow it with an Array of description lines, the description still gets silently omitted. ```ruby opts.on('-m', '--multiline-opt VALUE', String, ['Line one', 'Line two']) do |test| end ``` ``` usage: test.rb [options] -o, --opt [OPT] Line one -m, --multiline-opt VALUE -h, --help Prints this help ``` ---------------------------------------- Bug #20328: optparse omits the option's description in the --help output if the description is an Array https://bugs.ruby-lang.org/issues/20328#change-107161 * Author: postmodern (Hal Brodigan) * Status: Open * ruby -v: ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- If you define an option using `OptionParser#on`, but give the option's description as a multi-line Array, then the option's description is omitted from the `--help` output. ## Steps To Reproduce ```ruby #!/usr/bin/env ruby require 'optparse' optparser = OptionParser.new do |opts| opts.banner = 'usage: test.rb [options]' opts.on('-o', '--opt [OPT]', 'Line one') do |opt| end opts.on('-m', '--multiline-opt', ['Line one', 'Line two']) do |test| end opts.on('-h', '--help', 'Prints this help') do puts opts exit end end optparser.parse(['--help']) ``` ### Expected result ``` usage: test.rb [options] -o, --opt [OPT] Line one -m, --multiline-opt Line one Line two -h, --help Prints this help ``` ### Actual Result ``` usage: test.rb [options] -o, --opt [OPT] Line one -m, --multiline-opt -h, --help Prints this help ``` or an `ArgumentError` should be raised if Array descriptions are not allowed/supported. ## Version Info Tested against optparse 0.1.0, 0.2.0, 0.3.1, and the master branch. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/