All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.contek.warlock.server.command.CommandHandler Maven / Gradle / Ivy

There is a newer version: 1.2.2
Show newest version
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