@Test public void testFormatShortSyntax() { ArgumentParserImpl ap = (ArgumentParserImpl) ArgumentParsers .newFor("prog").build(); SubparsersImpl subparsers = new SubparsersImpl(ap); assertEquals("{}", subparsers.formatShortSyntax()); subparsers.addParser("install"); assertEquals("{install}", subparsers.formatShortSyntax()); subparsers.addParser("checkout"); assertEquals("{install,checkout}", subparsers.formatShortSyntax()); subparsers.metavar("COMMAND"); assertEquals("COMMAND", subparsers.formatShortSyntax()); }
String formatShortSyntax() { if (metavar_.isEmpty()) { StringBuilder sb = new StringBuilder(); sb.append("{"); for (Map.Entry<String, SubparserImpl> entry : parsers_.entrySet()) { if (entry.getValue().getHelpControl() != FeatureControl.SUPPRESS) { sb.append(entry.getKey()).append(","); } } if (sb.length() > 1) { sb.delete(sb.length() - 1, sb.length()); } sb.append("}"); return sb.toString(); } else { return metavar_; } }
SubparsersImpl implements Subparsers { String formatShortSyntax() { if (metavar_.isEmpty()) { StringBuilder sb = new StringBuilder(); sb.append("{"); for (Map.Entry<String, SubparserImpl> entry : parsers_.entrySet()) { if (entry.getValue().getHelpControl() != FeatureControl.SUPPRESS) { sb.append(entry.getKey()).append(","); } } if (sb.length() > 1) { sb.delete(sb.length() - 1, sb.length()); } sb.append("}"); return sb.toString(); } else { return metavar_; } } }
SubparsersImpl implements Subparsers { String formatShortSyntax() { if (metavar_.isEmpty()) { StringBuilder sb = new StringBuilder(); sb.append("{"); for (Map.Entry<String, SubparserImpl> entry : parsers_.entrySet()) { if (entry.getValue().getHelpControl() != FeatureControl.SUPPRESS) { sb.append(entry.getKey()).append(","); } } if (sb.length() > 1) { sb.delete(sb.length() - 1, sb.length()); } sb.append("}"); return sb.toString(); } else { return metavar_; } } SubparsersImpl(ArgumentParserImpl mainParser); }
SubparsersImpl implements Subparsers { String formatShortSyntax() { if (metavar_.isEmpty()) { StringBuilder sb = new StringBuilder(); sb.append("{"); for (Map.Entry<String, SubparserImpl> entry : parsers_.entrySet()) { if (entry.getValue().getHelpControl() != FeatureControl.SUPPRESS) { sb.append(entry.getKey()).append(","); } } if (sb.length() > 1) { sb.delete(sb.length() - 1, sb.length()); } sb.append("}"); return sb.toString(); } else { return metavar_; } } SubparsersImpl(ArgumentParserImpl mainParser); @Override SubparserImpl addParser(String command); @Override SubparserImpl addParser(String command, boolean addHelp); @Override SubparserImpl addParser(String command, boolean addHelp,
            String prefixChars); @Override SubparsersImpl dest(String dest); @Override SubparsersImpl help(String help); @Override SubparsersImpl title(String title); String getTitle(); @Override SubparsersImpl description(String description); String getDescription(); @Override SubparsersImpl metavar(String metavar); }
SubparsersImpl implements Subparsers { String formatShortSyntax() { if (metavar_.isEmpty()) { StringBuilder sb = new StringBuilder(); sb.append("{"); for (Map.Entry<String, SubparserImpl> entry : parsers_.entrySet()) { if (entry.getValue().getHelpControl() != FeatureControl.SUPPRESS) { sb.append(entry.getKey()).append(","); } } if (sb.length() > 1) { sb.delete(sb.length() - 1, sb.length()); } sb.append("}"); return sb.toString(); } else { return metavar_; } } SubparsersImpl(ArgumentParserImpl mainParser); @Override SubparserImpl addParser(String command); @Override SubparserImpl addParser(String command, boolean addHelp); @Override SubparserImpl addParser(String command, boolean addHelp,
            String prefixChars); @Override SubparsersImpl dest(String dest); @Override SubparsersImpl help(String help); @Override SubparsersImpl title(String title); String getTitle(); @Override SubparsersImpl description(String description); String getDescription(); @Override SubparsersImpl metavar(String metavar);  }