Closed rsenden closed 1 month ago
We've now identified a much easier way to handle this; enum's can simply provide a toString()
method like the following:
@Override
public String toString() {
// Show and accept dashes instead of underscores when this
// enum is used in picocli options.
return name().replace('_', '-');
}
Picocli will display the toString()
value as completion candidates, and also properly resolve enum values when specified with dashes on the command line.
For consistency, enum values passed on the command line should use
-
as word separator, however enum values cannot contain a-
character. We have variousConverter
andIterable
implementations to convert-
to_
and vice versa, for example:OutputFormatConfigConverter
(also covers some additional functionality)ProgressWriterTypeConverter
We should check whether there's any way to have picocli automatically handle the
_
to/from-
conversion when processing option values and generating completion candidates.