use of org.aesh.command.settings.ManProvider in project infinispan by infinispan.
the class Help method execute.
@Override
public CommandResult execute(CommandInvocation commandInvocation) throws CommandException, InterruptedException {
Shell shell = commandInvocation.getShell();
if (manPages == null || manPages.size() == 0) {
shell.writeln("Call `help <command>` where command is one of:");
List<TerminalString> commandNames = ((ContextAwareCommandInvocation) commandInvocation).getContext().getRegistry().getAllCommandNames().stream().map(n -> new TerminalString(n)).collect(Collectors.toList());
// then we print out the completions
shell.write(Parser.formatDisplayListTerminalString(commandNames, shell.size().getHeight(), shell.size().getWidth()));
// then on the next line we write the line again
shell.writeln("");
return CommandResult.SUCCESS;
}
if (manPages.size() <= 0) {
shell.write("No manual entry for " + manPages.get(0) + Config.getLineSeparator());
return CommandResult.SUCCESS;
}
if (manProvider == null) {
shell.write("No manual provider defined");
return CommandResult.SUCCESS;
}
InputStream inputStream = manProvider.getManualDocument(manPages.get(0));
if (inputStream != null) {
setCommandInvocation(commandInvocation);
try {
fileParser.setInput(inputStream);
afterAttach();
} catch (IOException ex) {
throw new CommandException(ex);
}
}
return CommandResult.SUCCESS;
}
Aggregations