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

io.vertx.ext.shell.command.CommandProcess Maven / Gradle / Ivy

There is a newer version: 5.0.0.CR1
Show newest version
/*
 * Copyright 2015 Red Hat, Inc.
 *
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  and Apache License v2.0 which accompanies this distribution.
 *
 *  The Eclipse Public License is available at
 *  http://www.eclipse.org/legal/epl-v10.html
 *
 *  The Apache License v2.0 is available at
 *  http://www.opensource.org/licenses/apache2.0.php
 *
 *  You may elect to redistribute this code under either of these licenses.
 *
 *
 * Copyright (c) 2015 The original author or authors
 * ------------------------------------------------------
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Apache License v2.0 which accompanies this distribution.
 *
 *     The Eclipse Public License is available at
 *     http://www.eclipse.org/legal/epl-v10.html
 *
 *     The Apache License v2.0 is available at
 *     http://www.opensource.org/licenses/apache2.0.php
 *
 * You may elect to redistribute this code under either of these licenses.
 *
 */

package io.vertx.ext.shell.command;

import io.vertx.codegen.annotations.Fluent;
import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.cli.CommandLine;
import io.vertx.ext.shell.session.Session;
import io.vertx.ext.shell.term.Tty;
import io.vertx.ext.shell.cli.CliToken;

import java.util.List;

/**
 * The command process provides interaction with the process of the command provided by Vert.x Shell.
 *
 * @author Julien Viet
 */
@VertxGen
public interface CommandProcess extends Tty {

  /**
   * @return the current Vert.x instance
   */
  Vertx vertx();

  /**
   * @return the unparsed arguments tokens
   */
  List argsTokens();

  /**
   * @return the actual string arguments of the command
   */
  List args();

  /**
   * @return the command line object or null
   */
  CommandLine commandLine();

  /**
   * @return the shell session
   */
  Session session();

  /**
   * @return true if the command is running in foreground
   */
  boolean isForeground();

  @Fluent
  CommandProcess stdinHandler(Handler handler);

  /**
   * Set an interrupt handler, this handler is called when the command is interrupted, for instance user
   * press Ctrl-C.
   *
   * @param handler the interrupt handler
   * @return this command
   */
  @Fluent
  CommandProcess interruptHandler(Handler handler);

  /**
   * Set a suspend handler, this handler is called when the command is suspended, for instance user
   * press Ctrl-Z.
   *
   * @param handler the interrupt handler
   * @return this command
   */
  @Fluent
  CommandProcess suspendHandler(Handler handler);

  /**
   * Set a resume handler, this handler is called when the command is resumed, for instance user
   * types bg or fg to resume the command.
   *
   * @param handler the interrupt handler
   * @return this command
   */
  @Fluent
  CommandProcess resumeHandler(Handler handler);

  /**
   * Set an end handler, this handler is called when the command is ended, for instance the command is running
   * and the shell closes.
   *
   * @param handler the end handler
   * @return a reference to this, so the API can be used fluently
   */
  @Fluent
  CommandProcess endHandler(Handler handler);

  /**
   * Write some text to the standard output.
   *
   * @param data the text
   * @return a reference to this, so the API can be used fluently
   */
  @Fluent
  CommandProcess write(String data);

  /**
   * Set a background handler, this handler is called when the command is running and put to background.
   *
   * @param handler the background handler
   * @return this command
   */
  @Fluent
  CommandProcess backgroundHandler(Handler handler);

  /**
   * Set a foreground handler, this handler is called when the command is running and put to foreground.
   *
   * @param handler the foreground handler
   * @return this command
   */
  @Fluent
  CommandProcess foregroundHandler(Handler handler);

  @Override
  CommandProcess resizehandler(Handler handler);

  /**
   * End the process with the exit status {@literal 0}
   */
  void end();

  /**
   * End the process.
   *
   * @param status the exit status.
   */
  void end(int status);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy