-
Notifications
You must be signed in to change notification settings - Fork 853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for javac-style @params files #77
Conversation
If I were doing this on a Linux box I'd just write |
Maybe. I think, not. The main problem is the command line / shell environment on Windows. If those programs you mention exists on Windows, they'll still use the non-Unicode ... shell thing. If I'm not missing something, it would still not work. See the String expected = "ℕ.java";
String actual = "N.java" And this is a good (human-readable) guess -- almost all other Unicode characters are translated to |
Path path = Paths.get(value); | ||
try { | ||
for (String line : Files.readAllLines(path, StandardCharsets.UTF_8)) { | ||
line = line.trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this line would be less bug-prone if it were replaced with CharMatcher.whitespace().trimFrom(line)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced.
What do you think about supporting javac-style |
In progress... |
Ah, with escaping. Check. |
Expand the "args" in I go with the second option for an initial PR. |
Ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM aside from a couple of minor questions.
@@ -119,6 +119,37 @@ public void testMain() throws Exception { | |||
assertThat(process.exitValue()).isEqualTo(0); | |||
} | |||
|
|||
@Test | |||
// https://stackoverflow.com/questions/7660651/passing-command-line-unicode-argument-to-java-code | |||
public void testMainWithUnicodeArgumentFailsOnWindows() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you want to include this test, or was it more to document the problem? I guess it would provide some notice if this changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only demonstrates the underlying issue why I needed that --sourceFile
feature.
I think, it's superseded by now and I'll remove it from this PR.
CommandLineOptions options = | ||
CommandLineOptionsParser.parse(Arrays.asList("@" + path.toString())); | ||
assertThat(options.files()).containsExactly("Hello.java", "ℕ.java", "Goodbye.java"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also test non-params file arguments before/after the params file, the @@
-escape syntax, and maybe a nested params file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
Should we also support comment lines? Meaning ignore lines that start with |
Almost down to a single feature branch. :) |
This PR adds support for javac-style @params files.
Example:
@params.txt
:This solves two problems with current command line program:
params.txt
may contain Unicode source file names. See https://stackoverflow.com/questions/7660651/passing-command-line-unicode-argument-to-java-code