Check whether picocli can be customized to automatically convert `_` to `-` in enum values
For consistency, enum values passed on the command line should use - as word separator, however enum values cannot contain a - character. We have various Converter and Iterable 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.
See https://github.com/remkop/picocli/issues/2025
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.