question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for option modifiers

See original GitHub issue

The programmer can enable modifiers for options which changes how the cli interprets the value for the option. Inspired by the Java Keytool

For example: -option value would use the value directly for option. -option:env value would treat value as a environment variable to look up for the actual value to supply to option. -option:file value would treat value as a path to a file to read for the value supplied to option

Useful for application wishing to hide sensitive information, such as passwords, from the command line.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
remkopcommented, Nov 2, 2017

To summarize, the password prompting feature is covered by this ticket: #82. Other than that, -option, -option:env and -option:file options are treated as separate options by picocli, which provides the building blocks to build a custom solution as described in my previous comment.

I won’t look further at providing special library support for option modifiers, unless something new comes up.

Still this is a good idea to either write an article about or mention in the user manual after #82 is implemented. (I added this to the list in the wiki: https://github.com/remkop/picocli/wiki/Plans-and-Notes-for-Future-Articles)

0reactions
remkopcommented, Oct 1, 2017

I’ve thought about this some more and I was wondering if special support is really needed. One can already do this:

class Args {
    @Option(names = "-option", description = "the option value")
    String option;

    @Option(names = "-option:env", description = "the environment variable to look up for the actual value")
    String optionEnvKey;

    @Option(names = "-option:file", description = "path to the file containing the option value")
    File optionFile;
}

The usage help for such a class looks exactly as one would expect:

Usage: <main class> [-option=<option>] [-option:env=<optionEnvKey>] [-option:
                    file=<optionFile>]
      -option=<option>        the option value
      -option:env=<optionEnvKey>
                              the environment variable to look up for the
                                actual value
      -option:file=<optionFile>
                              path to the file containing the option value

Wouldn’t it be better to leave the next step (calling System.getenv(args.optionEnvKey) or Files.readAllBytes(optionFile.toPath())) to the application?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create and Manage Item Modifiers | Square Support Center - US
Enter a name for the modifier set and select the items you'd like to apply it to. Toggle on Customer must only select...
Read more >
Advanced Modifier Features - Revel Support
Go to the Products tab. Click the icon in line with the modifier class. Click the checkbox labeled Allow Split Modifiers: Click Save....
Read more >
Option Rules vs Modifiers - BigCommerce Support
Any adjusters you set via API for a modifier will be found in the Rules section under Modifiers within the control panel, these...
Read more >
Modifiers - ShopKeep Support - Lightspeed
Learn about modifiers! Allow customers to request add-ons, substitute or request 'no' to customize basic inventory items. Watch our Youtube tutorial video!
Read more >
Add support for keep option modifier `includecode` [134838460]
Specifies that code attributes of the methods that the -keep option keeps should be kept as well, i.e. may not be optimized or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found