@Test public void testSimpleCommand() { CommandLineParser<CommandInvocation> parser = getParser(TestCommand1.class); FileCompleterGenerator completerGenerator = new FileCompleterGenerator(); String out = completerGenerator.generateCompleterFile(parser); assertTrue(out.contains("_complete_test1")); assertTrue(out.contains("NO_VALUE_OPTIONS=\"--help -h \"")); assertTrue(out.contains("VALUE_OPTIONS=\"--override -o --test -t \"")); }
String generateCompleterFile(CommandLineParser<CommandInvocation> command) { StringBuilder out = new StringBuilder(); out.append(generateHeader(command.getProcessedCommand().name())); if(command.isGroupCommand()) out.append(generateArrContains()); out.append(generateMainCompletion(command)); out.append(generateCommand(command)) ; if(command.isGroupCommand()) for(CommandLineParser<CommandInvocation> child : command.getAllChildParsers()) out.append(generateCommand(child)); out.append(generateFooter(command.getProcessedCommand().name())); return out.toString(); }
FileCompleterGenerator { String generateCompleterFile(CommandLineParser<CommandInvocation> command) { StringBuilder out = new StringBuilder(); out.append(generateHeader(command.getProcessedCommand().name())); if(command.isGroupCommand()) out.append(generateArrContains()); out.append(generateMainCompletion(command)); out.append(generateCommand(command)) ; if(command.isGroupCommand()) for(CommandLineParser<CommandInvocation> child : command.getAllChildParsers()) out.append(generateCommand(child)); out.append(generateFooter(command.getProcessedCommand().name())); return out.toString(); } }
FileCompleterGenerator { String generateCompleterFile(CommandLineParser<CommandInvocation> command) { StringBuilder out = new StringBuilder(); out.append(generateHeader(command.getProcessedCommand().name())); if(command.isGroupCommand()) out.append(generateArrContains()); out.append(generateMainCompletion(command)); out.append(generateCommand(command)) ; if(command.isGroupCommand()) for(CommandLineParser<CommandInvocation> child : command.getAllChildParsers()) out.append(generateCommand(child)); out.append(generateFooter(command.getProcessedCommand().name())); return out.toString(); }  }
FileCompleterGenerator { String generateCompleterFile(CommandLineParser<CommandInvocation> command) { StringBuilder out = new StringBuilder(); out.append(generateHeader(command.getProcessedCommand().name())); if(command.isGroupCommand()) out.append(generateArrContains()); out.append(generateMainCompletion(command)); out.append(generateCommand(command)) ; if(command.isGroupCommand()) for(CommandLineParser<CommandInvocation> child : command.getAllChildParsers()) out.append(generateCommand(child)); out.append(generateFooter(command.getProcessedCommand().name())); return out.toString(); }   }
FileCompleterGenerator { String generateCompleterFile(CommandLineParser<CommandInvocation> command) { StringBuilder out = new StringBuilder(); out.append(generateHeader(command.getProcessedCommand().name())); if(command.isGroupCommand()) out.append(generateArrContains()); out.append(generateMainCompletion(command)); out.append(generateCommand(command)) ; if(command.isGroupCommand()) for(CommandLineParser<CommandInvocation> child : command.getAllChildParsers()) out.append(generateCommand(child)); out.append(generateFooter(command.getProcessedCommand().name())); return out.toString(); }    }