@Test public void testAddAlias() { ArgumentParserImpl ap = (ArgumentParserImpl) ArgumentParsers .newFor("prog").build(); SubparsersImpl subparsers = new SubparsersImpl(ap); SubparserImpl subParser = subparsers.addParser("checkout"); subparsers.addAlias(subParser, "co", "out"); assertTrue(subparsers.getCommands().contains("co")); assertTrue(subparsers.getCommands().contains("out")); try { subparsers.addAlias(subParser, "co"); } catch(IllegalArgumentException e) { assertEquals("command 'co' has been already used", e.getMessage()); } }
void addAlias(SubparserImpl subparser, String... alias) { for (String command : alias) { if (parsers_.containsKey(command)) { throw new IllegalArgumentException(String.format( TextHelper.LOCALE_ROOT, "command '%s' has been already used", command)); } else { parsers_.put(command, subparser); } } }
SubparsersImpl implements Subparsers { void addAlias(SubparserImpl subparser, String... alias) { for (String command : alias) { if (parsers_.containsKey(command)) { throw new IllegalArgumentException(String.format( TextHelper.LOCALE_ROOT, "command '%s' has been already used", command)); } else { parsers_.put(command, subparser); } } } }
SubparsersImpl implements Subparsers { void addAlias(SubparserImpl subparser, String... alias) { for (String command : alias) { if (parsers_.containsKey(command)) { throw new IllegalArgumentException(String.format( TextHelper.LOCALE_ROOT, "command '%s' has been already used", command)); } else { parsers_.put(command, subparser); } } } SubparsersImpl(ArgumentParserImpl mainParser); }
SubparsersImpl implements Subparsers { void addAlias(SubparserImpl subparser, String... alias) { for (String command : alias) { if (parsers_.containsKey(command)) { throw new IllegalArgumentException(String.format( TextHelper.LOCALE_ROOT, "command '%s' has been already used", command)); } else { parsers_.put(command, subparser); } } } 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 { void addAlias(SubparserImpl subparser, String... alias) { for (String command : alias) { if (parsers_.containsKey(command)) { throw new IllegalArgumentException(String.format( TextHelper.LOCALE_ROOT, "command '%s' has been already used", command)); } else { parsers_.put(command, subparser); } } } 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);  }