Comments (5)
The CommandSpec.mixinStandardHelpOptions(true)
mixin is defined with variables, by design, to allow applications to customize the help options names without needing to define these options from scratch in their application.
There's a common use case that people want a lowercase short option -v
for version information, as opposed to the standard built-in uppercase -V
option. This use case is easily served with the variables.
However the variables get in the way for your use case where you want to reuse description strings between a GUI application and a CLI application. I believe this is a rare use case that requires a solution in the application, not in the picocli library.
Some solutions that come to mind are defining your own help/version options without variables, or replacing $
dollar characters in the descriptions with double $$
dollars before using those descriptions in the CLI.
from picocli.
Hi @VirtualTim, thank you for raising this!
Would it help your use case to escape the dollar sign with another dollar sign, like this: $${test}
?
An alternative to embedded %n
newline format specifiers is to split the description for the option into multiple Strings. Just like multiple option names can be specified as an array of Strings, so can the description. Picocli will render each element of the description Strings array on separate lines. For example:
@Option(names = "--openId.AuthorizationEndpoint",
description = { "Endpoint for authorization.",
"Current value: $${test}" })
from picocli.
Thanks @remkop, that could kind of work, the issue is that I'm using picocli as a cli for a GUI application. So the current value is the actual value used in the GUI.
I realise that I could run string replacement on the description, and replace $
with $$
, but it seems inefficient. It seems weird/inefficient to programatically add a $
only for picocli to later remove the $
from the same string.
I guess that solution is probably good enough, I was just hoping that I missed a setting.
from picocli.
Hi @VirtualTim glad to hear that.
Can I conclude that you have a solution for your use case and no further work is required for this ticket?
from picocli.
Yeah that's fine, I was just hoping for a more idiomatic solution.
Do you consider the interaction between CommandSpec.mixinStandardHelpOptions(true)
and CommandSpec.interpolateVariables(false)
a bug?
Would you like me to raise a separate issue?
from picocli.
Related Issues (20)
- Clarification about repeatable subcommand HOT 7
- Use picocli without Reflection API HOT 1
- ManPageGenerator fails with Quarkus
- Setter method annotated by @Option with default value not been invoked when reusing it HOT 2
- ITypeConverter for custom generics (type constructors) HOT 4
- Configuring end-of-options position after parameter HOT 2
- How to solve the problem of garbled Chinese output HOT 6
- Contribute a change in docs HOT 2
- picocli-shell-jline3 jpms module HOT 3
- CLI library learning
- PicocliCommands.java:283: error: [Overrides] Varargs doesn't agree for overridden method
- Build is Broken HOT 3
- Failed to instantiate [java.util.List]: Specified class is an interface HOT 2
- JLine3 Signal Handling HOT 2
- Documentation unclear re. default for negatable options HOT 2
- Failed to use subcommand CommandLine to execute command HOT 2
- picocli-codegen does not generate native-image.properties HOT 5
- Interactive option is missing some keystrokes on Windows HOT 7
- `IExecutionExceptionHandler` does not provided parsed ParseResult HOT 15
- ArgGroup with multiplicity 1 is validated "too" late HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from picocli.