I am using picocli to show the usage of my command-line application. What I am not able to reach is to hide the name of the Java variable which appears in the printed output and from my point of view it looks so ugly.
This is the configutation of my CommandLine.Option
:
@CommandLine.Option(
names = {"-a", "--abc"},
description = "Please, hide the Java variable name...")
private String xxx;
And this is how it is rendered:
-a, --abc=<xxx> Please, hide the Java variable name...
As you can see the name of the Java variable appears after the equal sign: <xxx>
I would like to hide it, like this:
-a, --abc Please, hide the Java variable name...
I checked the API but I could not see anything related to this. Is there any way to turn it off?
The picocli annotations API does not provide for this, but it is possible to achieve this by overriding the Help API and plugging in your own option renderer. For example:
This shows the following usage help message:
Note that the parameter label is omitted in the options list, but is still shown in the synopsis. If you do not want any parameter labels shown in the synopsis, you can specify a custom synopsis in the
@Command
annotation, see this section in the user manual.