Coder Social home page Coder Social logo

Comments (5)

remkop avatar remkop commented on May 24, 2024 1

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.

remkop avatar remkop commented on May 24, 2024

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.

VirtualTim avatar VirtualTim commented on May 24, 2024

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.

remkop avatar remkop commented on May 24, 2024

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.

VirtualTim avatar VirtualTim commented on May 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.