@Test public void testParseKnownArgs() throws ArgumentParserException { ap = (ArgumentParserImpl) ArgumentParsers.newFor("argparse4j") .addHelp(true).prefixChars("-+").build(); ap.addArgument("-f"); ap.addArgument("-g"); ap.addArgument("+a").action(Arguments.storeTrue()); ap.addArgument("path"); List<String> unknown = new ArrayList<String>(); Namespace res = ap.parseKnownArgs( "p -f a b -g c d -i k --i +abc".split(" "), unknown); assertEquals(unknown, asList("b", "d", "-i", "k", "--i", "+bc")); assertEquals("a", res.get("f")); assertEquals("c", res.get("g")); assertEquals("p", res.get("path")); unknown.clear(); Map<String, Object> attrs = new HashMap<String, Object>(); ap.parseKnownArgs("p q".split(" "), unknown, attrs); assertEquals(unknown, singletonList("q")); assertEquals("p", attrs.get("path")); unknown.clear(); attrs.clear(); class Out { @Arg(dest = "path") private String path; } Out out = new Out(); ap.parseKnownArgs("p q".split(" "), unknown, out); assertEquals(unknown, singletonList("q")); assertEquals("p", out.path); unknown.clear(); attrs.clear(); out = new Out(); ap.parseKnownArgs("p q".split(" "), unknown, attrs, out); assertEquals(unknown, singletonList("q")); assertEquals("p", attrs.get("path")); assertEquals("p", out.path); }
@Override public Namespace parseKnownArgs(String args[], List<String> unknown) throws ArgumentParserException { Map<String, Object> attrs = new HashMap<String, Object>(); parseKnownArgs(args, unknown, attrs); return new Namespace(attrs); }
ArgumentParserImpl implements ArgumentParser { @Override public Namespace parseKnownArgs(String args[], List<String> unknown) throws ArgumentParserException { Map<String, Object> attrs = new HashMap<String, Object>(); parseKnownArgs(args, unknown, attrs); return new Namespace(attrs); } }
ArgumentParserImpl implements ArgumentParser { @Override public Namespace parseKnownArgs(String args[], List<String> unknown) throws ArgumentParserException { Map<String, Object> attrs = new HashMap<String, Object>(); parseKnownArgs(args, unknown, attrs); return new Namespace(attrs); } ArgumentParserImpl(ArgumentParserConfigurationImpl config);  ArgumentParserImpl(ArgumentParserConfigurationImpl config,
            String command, ArgumentParserImpl mainParser); }
ArgumentParserImpl implements ArgumentParser { @Override public Namespace parseKnownArgs(String args[], List<String> unknown) throws ArgumentParserException { Map<String, Object> attrs = new HashMap<String, Object>(); parseKnownArgs(args, unknown, attrs); return new Namespace(attrs); } ArgumentParserImpl(ArgumentParserConfigurationImpl config);  ArgumentParserImpl(ArgumentParserConfigurationImpl config,
            String command, ArgumentParserImpl mainParser); @Override ArgumentImpl addArgument(String... nameOrFlags); ArgumentImpl addArgument(ArgumentGroupImpl group,
            String... nameOrFlags); @Override SubparsersImpl addSubparsers(); @Override ArgumentGroup addArgumentGroup(String title); @Override MutuallyExclusiveGroup addMutuallyExclusiveGroup(); @Override MutuallyExclusiveGroup addMutuallyExclusiveGroup(String title); @Override ArgumentParserImpl usage(String usage); @Override ArgumentParserImpl description(String description); @Override ArgumentParserImpl epilog(String epilog); @Override ArgumentParserImpl version(String version); @Override ArgumentParserImpl defaultHelp(boolean defaultHelp); @Override void printHelp(); @Override void printHelp(PrintWriter writer); @Override String formatHelp(); @Override void printUsage(); @Override void printUsage(PrintWriter writer); @Override String formatUsage(); @Override ArgumentParserImpl setDefault(String dest, Object value); @Override ArgumentParserImpl setDefaults(Map<String, Object> attrs); @Override Object getDefault(String dest); @Override Namespace parseArgsOrFail(String args[]); @Override Namespace parseKnownArgsOrFail(String args[], List<String> unknown); @Override Namespace parseArgs(String args[]); @Override Namespace parseKnownArgs(String args[], List<String> unknown); @Override void parseArgs(String[] args, Map<String, Object> attrs); @Override void parseKnownArgs(String[] args, List<String> unknown,
            Map<String, Object> attrs); @Override void parseArgs(String[] args, Object userData); @Override void parseKnownArgs(String[] args, List<String> unknown,
            Object userData); @Override void parseArgs(String[] args, Map<String, Object> attrs,
            Object userData); @Override void parseKnownArgs(String[] args, List<String> unknown,
            Map<String, Object> attrs, Object userData); void parseArgs(ParseState state, Map<String, Object> attrs); @Override ArgumentParserConfigurationImpl getConfig(); String getProg(); @Override void printVersion(); @Override void printVersion(PrintWriter writer); @Override String formatVersion(); @Override void handleError(ArgumentParserException e); @Override void handleError(ArgumentParserException e, PrintWriter writer); String getCommand(); String getPrefixChars(); String getFromFilePrefixChars(); }
ArgumentParserImpl implements ArgumentParser { @Override public Namespace parseKnownArgs(String args[], List<String> unknown) throws ArgumentParserException { Map<String, Object> attrs = new HashMap<String, Object>(); parseKnownArgs(args, unknown, attrs); return new Namespace(attrs); } ArgumentParserImpl(ArgumentParserConfigurationImpl config);  ArgumentParserImpl(ArgumentParserConfigurationImpl config,
            String command, ArgumentParserImpl mainParser); @Override ArgumentImpl addArgument(String... nameOrFlags); ArgumentImpl addArgument(ArgumentGroupImpl group,
            String... nameOrFlags); @Override SubparsersImpl addSubparsers(); @Override ArgumentGroup addArgumentGroup(String title); @Override MutuallyExclusiveGroup addMutuallyExclusiveGroup(); @Override MutuallyExclusiveGroup addMutuallyExclusiveGroup(String title); @Override ArgumentParserImpl usage(String usage); @Override ArgumentParserImpl description(String description); @Override ArgumentParserImpl epilog(String epilog); @Override ArgumentParserImpl version(String version); @Override ArgumentParserImpl defaultHelp(boolean defaultHelp); @Override void printHelp(); @Override void printHelp(PrintWriter writer); @Override String formatHelp(); @Override void printUsage(); @Override void printUsage(PrintWriter writer); @Override String formatUsage(); @Override ArgumentParserImpl setDefault(String dest, Object value); @Override ArgumentParserImpl setDefaults(Map<String, Object> attrs); @Override Object getDefault(String dest); @Override Namespace parseArgsOrFail(String args[]); @Override Namespace parseKnownArgsOrFail(String args[], List<String> unknown); @Override Namespace parseArgs(String args[]); @Override Namespace parseKnownArgs(String args[], List<String> unknown); @Override void parseArgs(String[] args, Map<String, Object> attrs); @Override void parseKnownArgs(String[] args, List<String> unknown,
            Map<String, Object> attrs); @Override void parseArgs(String[] args, Object userData); @Override void parseKnownArgs(String[] args, List<String> unknown,
            Object userData); @Override void parseArgs(String[] args, Map<String, Object> attrs,
            Object userData); @Override void parseKnownArgs(String[] args, List<String> unknown,
            Map<String, Object> attrs, Object userData); void parseArgs(ParseState state, Map<String, Object> attrs); @Override ArgumentParserConfigurationImpl getConfig(); String getProg(); @Override void printVersion(); @Override void printVersion(PrintWriter writer); @Override String formatVersion(); @Override void handleError(ArgumentParserException e); @Override void handleError(ArgumentParserException e, PrintWriter writer); String getCommand(); String getPrefixChars(); String getFromFilePrefixChars();  }