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.

Multi-value option overwriting

See original GitHub issue

This code:

class Params {
  @Option(names = "-a")
  private String a;

  @Option(names = "-b", split = ",")
  private List<String> b;
}

String[] args = new String[] {
   "-a", "10",
   "-a", "11",
   "-b", "20,21",
   "-b", "22,23",
};

Params params = new Params();

new CommandLine(params)
   .setOverwrittenOptionsAllowed(true)
   .parse(args);

System.out.println(params.a);
System.out.println(params.b);

prints:

11
[20, 21, 22, 23]

The docs only mention single-value (-a above) overwriting and it’s working as expected. There doesn’t seem to be a way to apply the same to multi-value (-b above) options.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
remkopcommented, Oct 26, 2018

Thanks for following up.

I see your point. To be honest, until your request I had not considered applications might want to replace values instead of add to the collection for a multi-value option.

I understand you want to make this a first-class citizen of the library. I need to think about this some more.

If other people also want this feature, please leave a comment below.

0reactions
remkopcommented, Feb 15, 2022

Closing this issue. The current API supports the use case (via the @Option-annotated setter method).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Class: MultiValue
Override the UCI configuration name to read the option value from. By default, the configuration name is inherited from the parent Map.
Read more >
Work with Iterate Multivalue—ArcGIS Pro | Documentation
The Iterate Multivalue tool is used to iterate over airports, freeway exits, and recreational ... and the field values are overwritten for each...
Read more >
Overwriting Definition - Investopedia
Overwriting is a strategy to sell options that are overpriced under the assumption that the options won't get exercised.
Read more >
Settings bundle MultiValue default value not working
You need to ensure there isn't a previous user setting either. It overrides the default value (which is used only when the user...
Read more >
Multi-Value Column Tutorial - ManagedEsent - GitHub
Starting with Windows Vista there are two new options for multi-value indexing: ... To overwrite an existing column you must set the itagSequence, ......
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