io.contek.warlock.server.command.CommandHandler Maven / Gradle / Ivy
package io.contek.warlock.server.command;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Singleton;
import java.io.StringWriter;
import picocli.CommandLine;
@Singleton
public final class CommandHandler {
private final Injector injector;
@Inject
CommandHandler(Injector injector) {
this.injector = injector;
}
public CommandResult handle(String[] args) {
Injector childInjector = injector.createChildInjector(new CommandModule());
int exitCode = childInjector.getInstance(CommandLine.class).execute(args);
String output = childInjector.getInstance(StringWriter.class).toString();
return new CommandResult(exitCode, output);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy