Github user schaumb commented on a diff in the pull request: https://github.com/apache/commons-cli/pull/12#discussion_r121406356 --- Diff: src/test/java/org/apache/commons/cli/PatternOptionBuilderTest.java --- @@ -159,13 +161,12 @@ public void testURLPattern() throws Exception @Test public void testExistingFilePattern() throws Exception { - final Options options = PatternOptionBuilder.parsePattern("f<"); + final Options options = PatternOptionBuilder.parsePattern("f<g<"); final CommandLineParser parser = new PosixParser(); - final CommandLine line = parser.parse(options, new String[] { "-f", "test.properties" }); - - assertEquals("f value", new File("test.properties"), line.getOptionObject("f")); - - // todo test if an error is returned if the file doesn't exists (when it's implemented) + final CommandLine line = parser.parse(options, new String[] { "-f", "test.properties", "-g", "/dev/null" }); + + assertNotNull("option g not parsed, or not FileInputStream", (FileInputStream) line.getOptionObject("g")); + assertNull("option f parsed", (FileInputStream) line.getOptionObject("f")); --- End diff -- So basically `<` means this parameter is an existing file parameter. When I built the options manually, the type is what I need to set is `PatternOptionBuilder.EXISTING_FILE_VALUE`, which is `FileInputStream`. This is why think `line.getOptionObject("f")` need to return an object of type `FileInputStream`. Yes, It is null because test.properties does not exist, or not readable. This can be made clearer somehow. Another task is to find a cross-platform file which is exist (and not /dev/null).
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org