use of io.vertx.ext.shell.ShellService in project vertx-examples by vert-x3.
the class HelloWorldCommand method start.
@Override
public void start() throws Exception {
Command helloWorld = CommandBuilder.command("hello-world").processHandler(process -> {
process.write("hello world\n");
process.end();
}).build(vertx);
ShellService service = ShellService.create(vertx, new ShellServiceOptions().setTelnetOptions(new TelnetTermOptions().setHost("localhost").setPort(3000)));
CommandRegistry.getShared(vertx).registerCommand(helloWorld);
service.start(ar -> {
if (!ar.succeeded()) {
ar.cause().printStackTrace();
}
});
}
use of io.vertx.ext.shell.ShellService in project vertx-examples by vert-x3.
the class RunShell method start.
@Override
public void start(Future<Void> startFuture) throws Exception {
ShellService service = ShellService.create(vertx, new ShellServiceOptions().setHttpOptions(new HttpTermOptions().setHost("localhost").setPort(8080).setAuthOptions(new ShiroAuthOptions().setConfig(new JsonObject().put("properties_path", "auth.properties")))));
service.start(ar -> {
if (ar.succeeded()) {
startFuture.succeeded();
} else {
startFuture.fail(ar.cause());
}
});
}
use of io.vertx.ext.shell.ShellService in project vertx-examples by vert-x3.
the class RunShell method start.
@Override
public void start(Future<Void> startFuture) throws Exception {
ShellService service = ShellService.create(vertx, new ShellServiceOptions().setSSHOptions(new SSHTermOptions().setHost("localhost").setPort(3000).setKeyPairOptions(new JksOptions().setPath("keystore.jks").setPassword("wibble")).setAuthOptions(new ShiroAuthOptions().setConfig(new JsonObject().put("properties_path", "auth.properties")))));
service.start(ar -> {
if (ar.succeeded()) {
startFuture.succeeded();
} else {
startFuture.fail(ar.cause());
}
});
}
use of io.vertx.ext.shell.ShellService in project vertx-examples by vert-x3.
the class RunShell method start.
@Override
public void start(Promise<Void> startPromise) throws Exception {
ShellService service = ShellService.create(vertx, new ShellServiceOptions().setHttpOptions(new HttpTermOptions().setHost("localhost").setPort(8080).setAuthOptions(new ShiroAuthOptions().setConfig(new JsonObject().put("properties_path", "auth.properties")))));
service.start(startPromise);
}
use of io.vertx.ext.shell.ShellService in project vertx-examples by vert-x3.
the class WgetCommand method start.
@Override
public void start() throws Exception {
// Create the wget CLI
CLI cli = CLI.create("wget").setSummary("Wget implemented with Vert.x HTTP client").addArgument(new Argument().setIndex(0).setArgName("http-url").setDescription("the HTTP uri to get"));
// Create the command
Command helloWorld = CommandBuilder.command(cli).processHandler(process -> {
URL url;
try {
url = new URL(process.commandLine().getArgumentValue(0));
} catch (MalformedURLException e) {
process.write("Bad url\n").end();
return;
}
HttpClient client = process.vertx().createHttpClient();
process.write("Connecting to " + url + "\n");
int port = url.getPort();
if (port == -1) {
port = 80;
}
HttpClientRequest req = client.get(port, url.getHost(), url.getPath());
req.exceptionHandler(err -> {
process.write("wget: error " + err.getMessage() + "\n");
process.end();
});
req.handler(resp -> {
process.write(resp.statusCode() + " " + resp.statusMessage() + "\n");
String contentType = resp.getHeader("Content-Type");
String contentLength = resp.getHeader("Content-Length");
process.write("Length: " + (contentLength != null ? contentLength : "unspecified"));
if (contentType != null) {
process.write("[" + contentType + "]");
}
process.write("\n");
process.end();
});
req.end();
}).build(vertx);
ShellService service = ShellService.create(vertx, new ShellServiceOptions().setTelnetOptions(new TelnetTermOptions().setHost("localhost").setPort(3000)));
CommandRegistry.getShared(vertx).registerCommand(helloWorld);
service.start(ar -> {
if (!ar.succeeded()) {
ar.cause().printStackTrace();
}
});
}
Aggregations