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.

Map option problem when value contains '=' separator (was: How to quote / escape option values)

See original GitHub issue

I would like to pass a map of options into my application like: -p AppOptions="-Dspring.profiles.active=test -Dspring.mail.host=smtp.mailtrap.io"

picocli seems to get confused by the equals sign in the value. My class:

public class MyCommand implements Callable<Object> {
    @Option(names = {"-p", "--parameter"})
    @Getter
    Map<String, String> parameters;

    public static void main(String[] args) throws Exception {
        Object result = CommandLine.call(new MyCommand(), System.out, args);
        System.exit(result != null ? 0 : 1);
    }

    @Override
    public Object call() throws Exception {
        System.out.println(this.parameters.get("AppOptions"));
        return new Object();
    }
}

I expect it to output the entire value, but I’m only getting -Dspring.profiles.active. How can I escape the value correctly?

I don’t want to make AppOptions part of my CLI directly, because I don’t control the content and users should be able to pass in an arbitary set of parameters.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
remkopcommented, May 14, 2018

Picocli 3.0.1 is released with the fix for this bug. Thanks again for the bug report!

0reactions
MarkusKramercommented, May 16, 2018

Sure, I’ve created #379

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can someone explain me "TextQualifierEscape","Delimiter ...
Problem : You need to store a value in a flat file which contains the text qualifier (single or double quotes) in its...
Read more >
How to escape delimiter inside the value - Stack Overflow
I myself has used rdd with Python regex import re raw_string = r"(\\\|)" rdd_cleaned = rdd.map(lambda x: re.sub(raw_string, "", x)).
Read more >
Escape &quot;\&quot; backslash from dataweave for csv output.
If the `,` is not escaped, it can lead to a miss-interpretation/ambiguity. Is it a separator or comma? Therefore, as suggested by others...
Read more >
Spark Write DataFrame to CSV File
If you have a separator or delimiter part of your value, use the quote to set a single character used for escaping quoted...
Read more >
CSV Files - Spark 3.3.1 Documentation
Property Name Default Scope sep, read/write encoding UTF‑8 read/write quote " read/write
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