Re: [CLI] - new FormatHelper produces poorly formatted option groups
Claude Warren <[email protected]> Thu, 30 Oct 2025 12:47:56 +0000
| Newsgroups | gmane.comp.jakarta.commons.user |
|---|---|
| Message-ID | <CAOQrJk5qi3irRtneL4WDngiy6TzSpd6UU3r5vhbZyvjgceT8Qg@mail.gmail.com> |
--00000000000034aff706425fa9b9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Looks likeregression. I will take a look later today. Claude LinkedIn: http://www.linkedin.com/in/claudewarren On Thu 30 Oct 2025, 12:12 Gary Gregory, <[email protected]> wrote: > Claude, any thoughts here? I was just about to push a release candidate..= . > > Gary > > On Sun, Oct 26, 2025 at 10:38=E2=80=AFAM Damien Carbonne > <[email protected]> wrote: > > > > Hi, > > > > When using the new HelpFormatter (commons-cli-1.10.0), option groups ar= e > > poorly formatted. > > > > This looks like a regression. > > The following code shows the difference between the new HelpFormatter > > and the deprecated one: > > ------------------------------------- > > import java.io.IOException; > > > > import org.apache.commons.cli.Option; > > import org.apache.commons.cli.OptionGroup; > > import org.apache.commons.cli.Options; > > > > public class CliTest { > > public static void main(String[] args) throws IOException { > > // create options and groups > > final Option o1 =3D new Option("o1", "Descr"); > > final Option o2 =3D new Option("o2", "Descr"); > > > > final Options options =3D new Options(); > > options.addOption(o1); > > options.addOption(o2); > > > > final OptionGroup group =3D new OptionGroup(); > > group.addOption(o1); > > group.addOption(o2); > > options.addOptionGroup(group); > > > > //format options with new formatter > > final org.apache.commons.cli.help.HelpFormatter newFormatter = =3D > > > org.apache.commons.cli.help.HelpFormatter.builder().setShowSince(false).g= et(); > > newFormatter.printHelp("Command", null, options, null, true); > > > > // format options with old formatter > > final org.apache.commons.cli.HelpFormatter oldFormatter =3D > > new org.apache.commons.cli.HelpFormatter(); > > oldFormatter.printHelp("Command", null, options, null, true); > > } > > } > > ------------------------------------- > > > > The output is: > > ------------------------------------- > > usage: Command [-o1] [-o2] > > Options Description > > -o1 Descr > > -o2 Descr > > > > > > usage: Command [-o1 | -o2] > > -o1 Descr > > -o2 Descr > > ------------------------------------- > > > > Groups are not shown any more. > > I would expect the new formatter output to look like this: > > ------------------------------------- > > usage: Command [-o1 | -o2] > > Options Description > > -o1 Descr > > -o2 Descr > > -o3 Descr > > ------------------------------------- > > > > Regards, > > Damien Carbonne > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > --00000000000034aff706425fa9b9--