cbeust / jcommander

Command line parsing framework for Java
Apache License 2.0
1.95k stars 332 forks source link

Fixed #532 #533

Closed mkarg closed 2 years ago

mkarg commented 2 years ago

Fixed #532

mkarg commented 2 years ago

@cbeust I don't know if it was by intention that you enforced the values of arguments to be on a separate line below the name of option, but with this change the end user now can opt whether to stay with the two-lines syntax or go with a (more intuitive) single-line syntax ("--foo X"). Would be glad if you would adopt my change proposal. :-)

mkarg commented 2 years ago

Looking at what my PR currently does, it might be better to change the regex in a way that allows to limit the line split to a single one, so the value actually can contain blanks, like this: --foo bar baz (which aligns with the possibility of the inline argument --foo "bar baz"). For example, just apply the split "just once", not "for each". Or we could actually check the quotes, just like the command line does? WDYT?

cbeust commented 2 years ago

Would you mind adding a test?

mkarg commented 2 years ago

I would be glad to add a test, but we should first clarify the behavior it shall assert: Do we want the solution as-is (i. e. truncate at EACH blank) or do we instead want to "truncate at FIRST blank"?

mkarg commented 2 years ago

@cbeust Initial test "as-is" can be found in https://github.com/cbeust/jcommander/pull/533/commits/eee072ab324206ea6089676aad55b60fe3aba6cc. If we agree upon blank handling within values, I will modify it.