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

com.arangodb.shaded.vertx.core.spi.launcher.ExecutionContext Maven / Gradle / Ivy

There is a newer version: 7.8.0
Show newest version
/*
 * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
 * which is available at https://www.apache.org/licenses/LICENSE-2.0.
 *
 * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
 */

package com.arangodb.shaded.vertx.core.spi.launcher;

import com.arangodb.shaded.vertx.core.cli.CLI;
import com.arangodb.shaded.vertx.core.cli.CommandLine;
import com.arangodb.shaded.vertx.core.impl.launcher.VertxCommandLauncher;

import java.io.PrintStream;
import java.util.HashMap;

/**
 * The execution context contains various information on the execution.
 */
public class ExecutionContext extends HashMap {
  private final VertxCommandLauncher launcher;
  private final Command command;
  private final CommandLine commandLine;

  /**
   * Creates a new instance of {@link ExecutionContext}.
   *
   * @param command     the command instance that is executed
   * @param launcher    the launcher class
   * @param commandLine the command line
   */
  public ExecutionContext(Command command, VertxCommandLauncher launcher, CommandLine commandLine) {
    this.command = command;
    this.commandLine = commandLine;
    this.launcher = launcher;
  }

  /**
   * @return the command line object.
   */
  public Command command() {
    return command;
  }

  /**
   * @return the launcher.
   */
  public VertxCommandLauncher launcher() {
    return launcher;
  }

  /**
   * @return the {@link CLI}.
   */
  public CLI cli() {
    return commandLine.cli();
  }

  /**
   * @return the {@link CommandLine}.
   */
  public CommandLine commandLine() {
    return commandLine;
  }

  /**
   * Executes another command.
   *
   * @param command the command name
   * @param args    the arguments
   */
  public void execute(String command, String... args) {
    launcher.execute(command, args);
  }

  /**
   * @return the {@code Main-Class} object.
   */
  public Object main() {
    return get("Main");
  }

  /**
   * @return the {@link PrintStream} on which command can write.
   */
  public PrintStream getPrintStream() {
    return launcher.getPrintStream();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy