Commit f2cdb8c6 authored by Dave Syer's avatar Dave Syer

Change interface of CommandFactory slightly

It's super useful to get a reference to the current SpringCli
instance in the CommandFactory. Potentially implementations can
react to the properties of the Cli, or wrap it into something
more complex.

...supports the likely implementation of the REPL use
case that @jbrisbin has been working on.
parent e55e8f98
......@@ -31,6 +31,6 @@ public interface CommandFactory {
* Returns the CLI {@link Command}s.
* @return The commands
*/
Collection<Command> getCommands();
Collection<Command> getCommands(SpringCli cli);
}
......@@ -60,7 +60,7 @@ public class SpringCli {
private void setCommands(Iterable<CommandFactory> iterable) {
this.commands = new ArrayList<Command>();
for (CommandFactory factory : iterable) {
for (Command command : factory.getCommands()) {
for (Command command : factory.getCommands(this)) {
this.commands.add(command);
}
}
......
......@@ -22,6 +22,7 @@ import java.util.List;
import org.springframework.boot.cli.Command;
import org.springframework.boot.cli.CommandFactory;
import org.springframework.boot.cli.SpringCli;
/**
* Default implementation of {@link CommandFactory}.
......@@ -35,7 +36,7 @@ public class DefaultCommandFactory implements CommandFactory {
new TestCommand(), new GrabCommand());
@Override
public Collection<Command> getCommands() {
public Collection<Command> getCommands(SpringCli cli) {
return DEFAULT_COMMANDS;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment