-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Enhancement: Make Cli ArgumentParsers locale configurable #8619
Comments
Hi @JamesBoon. I don't think setting the Your second approach should be possible. The more flexible way in my opinion is to provide a general customizer for the |
If you use a I don't know what would be the best approach here. What do you think? Which way would lead to a better, more comfortable way for a developer using it? |
Hi @zUniQueX, These changes will just mark the |
@JamesBoon Looks good overall. But this only enables a few predefined options for customization. When we update the argparse4j dependency and they add new options, we'd have to add those options to our objects as well. I thought of a simpler solution, where we expose the |
That looks really good and would solve my specific problem. I like it! 👍 Perhaps one could combine our approaches to be able to configure the output of the version too. Maybe someone would like to have the Git hash included in the version number or similar... |
@zUniQueX thank you for your support on this topic! After experimenting a bit with the implementation using the ServiceLoader, here are my thoughts:
Actually only the third point (new way of configuring something) is actually something I am a bit concerned about. |
When creating a command in dropwizard, I usually add my help texts in english. This makes sense as dropwizards help texts are english too.
But argparse4j uses
Locale.getDefault()
and for this reason the output is in two different languages on each non-english system.I have two different proposals:
Just change the creation of the
ArgumentParser
here to set the english locale:final ArgumentParser p = ArgumentParsers.newFor(usage).locale(Locale.ENGLISH).addHelp(false).build()
This would be a breaking change though. But maybe possible for 5.0.0?
Or: Make it possible to somehow pass more options to the creation of the
ArgumentParser
. Maybe by enhancingJarLocation
. It could return the locale in a function likegetLocale()
(default:Locale.getDefault()
). Then a protected Function ofApplication<>
likegetJarLocation()
could be used here:final Cli cli = new Cli(getJarLocation(), bootstrap, System.out, System.err);
and the line from "1." would become:
final ArgumentParser p = ArgumentParsers.newFor(usage).locale(location.getLocale()).addHelp(false).build()
What do you think? Is one of these ways possible?
The text was updated successfully, but these errors were encountered: