server.shellHandler(shell -> { shell.setPrompt(s -> { try {
/** * Called when a new shell is created. Can be used to prepopulate the shell session with objects * or set the prompt. * @param shellHandler handler for getting notified when the server creates a new shell. */ public void shellHandler(Handler<io.vertx.rxjava.ext.shell.Shell> shellHandler) { delegate.shellHandler(new Handler<io.vertx.ext.shell.Shell>() { public void handle(io.vertx.ext.shell.Shell event) { shellHandler.handle(io.vertx.rxjava.ext.shell.Shell.newInstance(event)); } }); }
/** * Called when a new shell is created. Can be used to prepopulate the shell session with objects * or set the prompt. * @param shellHandler handler for getting notified when the server creates a new shell. */ public void shellHandler(Handler<io.vertx.rxjava.ext.shell.Shell> shellHandler) { delegate.shellHandler(new Handler<io.vertx.ext.shell.Shell>() { public void handle(io.vertx.ext.shell.Shell event) { shellHandler.handle(io.vertx.rxjava.ext.shell.Shell.newInstance(event)); } }); }
@Test public void testPrompt(TestContext context) { commands = new TestCommands(vertx); ShellServer server = ShellServer.create(vertx, new ShellServerOptions() .setWelcomeMessage("") .setSessionTimeout(100) .setReaperInterval(100)); server.shellHandler(shell -> shell.setPrompt(s -> "FOOPROMPT")); TestTermServer termServer = new TestTermServer(vertx); server.registerTermServer(termServer); server. registerCommandResolver(CommandResolver.baseCommands(vertx)). registerCommandResolver(commands). listen(context.asyncAssertSuccess()); TestTtyConnection conn = termServer.openConnection(); Async async = context.async(); commands.add(CommandBuilder.command("foo").processHandler(process -> { context.assertEquals(null, conn.checkWritten("FOOPROMPTfoo\n")); process.stdinHandler(cp -> { context.fail(); }); process.endHandler(v -> { async.complete(); } ); process.end(); })); conn.read("foo\r"); async.awaitSuccess(5000); }