Skip to content

Support JCommander-style parameter files #551

@triceo

Description

@triceo

It is possible that this is a feature, but I did not find it in the documentation. See my Github repo for a complete reproducer.

Steps to reproduce

Create an argument file argFile such as this:

-f "C:\Users\me\somefile.txt"

Run Picocli like this:

CommandLine.run(..., "@argFile");

Observe that the value of the String-typed Option has been changed to C:UsersmesomeFile.txt.

Additional information

  • When the value is not quoted, everything works fine. This suggests a problem with not escaping the Windows backslash character. However, the quotes are used in order not to have to escape whitespace characters and therefore this workaround creates a different problem - either I escape the backslashes or the whitespace.
  • When the value is kept quoted but passed directly on the command line (as opposed to the argument file), the problem no longer shows up. Unfortunately, the code will include the quotes in the resulting value. There is a second test included to showcase that problem.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions