Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standard help renders "Options" header when it is specified via optionListHeading even when there's only one hidden option #1071

Closed
mikosik opened this issue May 25, 2020 · 2 comments
Labels
theme: usagehelp An issue or change related to the usage help message type: bug 🐛
Milestone

Comments

@mikosik
Copy link

mikosik commented May 25, 2020

Code

import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.HelpCommand;
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.Option;
import picocli.CommandLine.Spec;

public class Main2 {
  public static void main(String[] args) {
    runMyTool("help");
  }

  private static void runMyTool(String... args) {
    CommandLine commandLine = new CommandLine(new MyTool());
    commandLine.execute(args);
  }
}

@Command(
    optionListHeading = "%n@|bold,underline Options:|@%n",
    subcommands = {HelpCommand.class}
)class MyTool implements Runnable {
  @Spec
  protected CommandSpec spec;

  @Option(
      names = { "--hidden" },
      hidden = true
  )
  String hidden = null;

  @Override
  public void run() {
    CommandLine commandLine = spec.commandLine();
    commandLine.usage(commandLine.getOut());
  }
}

actual output

Usage: <main class> [COMMAND]

Options:
Commands:
  help  Displays help information about the specified command

expected output: (without "Options:" line)

Usage: <main class> [COMMAND]

Commands:
  help  Displays help information about the specified command

bug summary

When Command has only hidden options and optionListHeading is specified for that command then option list heading is always printed by help subcommand.

EDIT:
picocli version 4.2.0

@remkop remkop added type: bug 🐛 theme: usagehelp An issue or change related to the usage help message labels May 26, 2020
@remkop remkop added this to the 4.4 milestone May 26, 2020
@remkop
Copy link
Owner

remkop commented May 26, 2020

Good catch! Thank you for raising this!
I'll put this on the todo list for the next release.

@remkop
Copy link
Owner

remkop commented Jun 4, 2020

Fixed in master. This will be part of the next 4.4 release.
Thanks again for raising this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: usagehelp An issue or change related to the usage help message type: bug 🐛
Projects
None yet
Development

No branches or pull requests

2 participants