@Test
public void topLevel() throws Exception {

    ArrayList<CharSequence> r = new ArrayList<>();
    complete("", r);
    OptionGroup<ID> options = OptionIntrospector.introspect(CSLTool.class);
    OptionGroup<ID> optionsAdditional = OptionIntrospector.introspect(
            AdditionalShellCommands.class);
    // get number of commands, subtract 1 because there's a HelpCommand
    // and a ShellHelpCommand
    int numCommands = options.getCommands().size() +
            optionsAdditional.getCommands().size() - 1;
    assertEquals(numCommands, r.size());
    for (Option<ID> o : options.getCommands()) {
        assertTrue(r.contains(o.getLongName()));
    }
    for (Option<ID> o : optionsAdditional.getCommands()) {
        assertTrue(r.contains(o.getLongName()));
    }
    r = new ArrayList<>();
    complete(" ", r);
    assertEquals(numCommands, r.size());
    r = new ArrayList<>();
    complete("     ", r);
    assertEquals(numCommands, r.size());
    r = new ArrayList<>();
    complete("bibl", r);
    assertEquals(1, r.size());
    assertEquals("bibliography", r.get(0));
    r = new ArrayList<>();
    complete("   bibl", r);
    assertEquals(1, r.size());
    assertEquals("bibliography", r.get(0));
    r = new ArrayList<>();
    complete("ge", r);
    assertEquals(1, r.size());
    assertEquals("get", r.get(0));
    r = new ArrayList<>();
    complete("bla", r);
    assertEquals(0, r.size());
}