command-line-arguments icon indicating copy to clipboard operation
command-line-arguments copied to clipboard

Parse error on heredoc-style argument specification on Windows

Open VantageKR opened this issue 5 years ago • 4 comments

Hi. Great library, but experienced an issue on Windows, Scala 2.11.12 with the heredoc-style argument specification as per the example:

VantageKR avatar Aug 21 '19 03:08 VantageKR

    val initialArgs: Args = """
      |run-main CLASampleMain [options]
      |Demonstrates the CLA API.
      |   -i | --in  | --input      string              Path to input file.
 

gives:

'error] (run-main-8) com.concurrentthought.cla.ParseError: Invalid input: `
[error]   Error:Unexpected end of input, expected Opt (line 1, pos 1):
[error]
[error] ^
[error] Nonzero exit code: 1

.. and is resolved by immediately starting the heredoc contents before the line break:

    val initialArgs: Args = """      |run-main CLASampleMain [options]
      |Demonstrates the CLA API.
      |   -i | --in  | --input      string              Path to input file.

Unrelated, but it would also be helpful if the docs could explain how to run the example code through SBT.

VantageKR avatar Aug 21 '19 03:08 VantageKR

Thanks for reporting these errors. I'll investigate later today.

deanwampler avatar Aug 21 '19 12:08 deanwampler

I think the bug is a spot in the parsing code where I first split on \n, which is wrong for Windows. I've changed that and added a test to make sure it handles \n and \r\n and doesn't assume that the files originated on the same kind of system (i.e., you parse a Linux-generated file on Windows...)

Right now I'm upgrading the code for Scala 2.13 and making other minor improvements. I'll try to have a new release out over the weekend.

deanwampler avatar Aug 23 '19 12:08 deanwampler

I just released v0.6.0, which I believe fixes the issue. Please let me know if it doesn't! The new jar files might take a few hours to propagate to Maven repos...

deanwampler avatar Aug 24 '19 13:08 deanwampler