I am not familiar with optparse-applyative, so I'm not sure what error printing tool it provides. (Sometimes parser combiner libraries offer a primitive that changes the printed error, but I did not see anything for this in the quick part of the document using optparse. It is possible that I skipped it.)
But in the event that nothing is available from the library itself, you can always print your own message by accepting both flags; eg.
data Exclusive = E1 | E2 | Both exclusiveParser = (flag' E1 (short 'e')) <|> (flag' E2 (short 'f')) <|> (flag' Both (short 'e') <* flag' Both (short 'f'))
Then, in your top-level handler (i.e., after all the parameters have been parsed), if you see Both , you can issue an error message about your own creation at this time.
source share