Search in sources :

Example 1 with CommandFactory

use of org.springframework.boot.cli.command.CommandFactory in project spring-boot by spring-projects.

the class Shell method getCommands.

private Iterable<Command> getCommands() {
    List<Command> commands = new ArrayList<>();
    ServiceLoader<CommandFactory> factories = ServiceLoader.load(CommandFactory.class, getClass().getClassLoader());
    for (CommandFactory factory : factories) {
        for (Command command : factory.getCommands()) {
            commands.add(convertToForkCommand(command));
        }
    }
    commands.add(new PromptCommand(this.prompts));
    commands.add(new ClearCommand(this.consoleReader));
    commands.add(new ExitCommand());
    return commands;
}
Also used : Command(org.springframework.boot.cli.command.Command) VersionCommand(org.springframework.boot.cli.command.core.VersionCommand) HelpCommand(org.springframework.boot.cli.command.core.HelpCommand) ArrayList(java.util.ArrayList) CommandFactory(org.springframework.boot.cli.command.CommandFactory)

Aggregations

ArrayList (java.util.ArrayList)1 Command (org.springframework.boot.cli.command.Command)1 CommandFactory (org.springframework.boot.cli.command.CommandFactory)1 HelpCommand (org.springframework.boot.cli.command.core.HelpCommand)1 VersionCommand (org.springframework.boot.cli.command.core.VersionCommand)1