/*
* 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
/**
* The command process provides interaction with the process of the command provided by Vert.x Shell.
*
* @author <a href="mailto:julien@julienviet.com">Julien Viet</a>
*/
@VertxGen
public interface CommandProcess extends Tty {
Returns: the current Vert.x instance
/**
* @return the current Vert.x instance
*/
Vertx vertx();
Returns: the unparsed arguments tokens
/**
* @return the unparsed arguments tokens
*/
List<CliToken> argsTokens();
Returns: the actual string arguments of the command
/**
* @return the actual string arguments of the command
*/
List<String> args();
Returns: the command line object or null
/**
* @return the command line object or null
*/
CommandLine commandLine();
Returns: the shell session
/**
* @return the shell session
*/
Session session();
Returns: true if the command is running in foreground
/**
* @return true if the command is running in foreground
*/
boolean isForeground();
@Fluent
CommandProcess stdinHandler(Handler<String> handler);
Set an interrupt handler, this handler is called when the command is interrupted, for instance user
press Ctrl-C
.
Params: - handler – the interrupt handler
Returns: this command
/**
* Set an interrupt handler, this handler is called when the command is interrupted, for instance user
* press <code>Ctrl-C</code>.
*
* @param handler the interrupt handler
* @return this command
*/
@Fluent
CommandProcess interruptHandler(Handler<Void> handler);
Set a suspend handler, this handler is called when the command is suspended, for instance user
press Ctrl-Z
.
Params: - handler – the interrupt handler
Returns: this command
/**
* Set a suspend handler, this handler is called when the command is suspended, for instance user
* press <code>Ctrl-Z</code>.
*
* @param handler the interrupt handler
* @return this command
*/
@Fluent
CommandProcess suspendHandler(Handler<Void> 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.
Params: - handler – the interrupt handler
Returns: this command
/**
* Set a resume handler, this handler is called when the command is resumed, for instance user
* types <code>bg</code> or <code>fg</code> to resume the command.
*
* @param handler the interrupt handler
* @return this command
*/
@Fluent
CommandProcess resumeHandler(Handler<Void> handler);
Set an end handler, this handler is called when the command is ended, for instance the command is running
and the shell closes.
Params: - handler – the end handler
Returns: a reference to this, so the API can be used fluently
/**
* 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<Void> handler);
Write some text to the standard output.
Params: - data – the text
Returns: a reference to this, so the API can be used fluently
/**
* 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.
Params: - handler – the background handler
Returns: this command
/**
* 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<Void> handler);
Set a foreground handler, this handler is called when the command is running and put to foreground.
Params: - handler – the foreground handler
Returns: this command
/**
* 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<Void> handler);
@Override
CommandProcess resizehandler(Handler<Void> handler);
End the process with the exit status 0 /**
* End the process with the exit status {@literal 0}
*/
void end();
End the process.
Params: - status – the exit status.
/**
* End the process.
*
* @param status the exit status.
*/
void end(int status);
}