@Override public void resolver(Vertx vertx, Handler<AsyncResult<CommandResolver>> handler) { handler.handle(Future.succeededFuture(() -> Stream.of(MetricsInfo.class, MetricsLs.class, MetricsHistogram.class) .map(cmd -> Command.create(vertx, cmd)).collect(Collectors.toList()))); } }
/** * Create a new process with empty arguments. * * @return the process */ default Process createProcess() { return createProcess(Collections.emptyList()); }
/** * @return the command name */ public String name() { String ret = delegate.name(); return ret; }
/** * Perform command completion, when the command is done completing it should call * or )} method to signal completion is done. * @param completion the completion object */ public void complete(io.vertx.rxjava.ext.shell.cli.Completion completion) { delegate.complete(completion.getDelegate()); }
/** * @return the command line interface, can be null */ public io.vertx.rxjava.core.cli.CLI cli() { io.vertx.rxjava.core.cli.CLI ret = io.vertx.rxjava.core.cli.CLI.newInstance(delegate.cli()); return ret; }
/** * Perform command completion, when the command is done completing it should call * or )} method to signal completion is done. * @param completion the completion object */ public void complete(io.vertx.rxjava.ext.shell.cli.Completion completion) { delegate.complete(completion.getDelegate()); }
/** * @return the command line interface, can be null */ public io.vertx.rxjava.core.cli.CLI cli() { io.vertx.rxjava.core.cli.CLI ret = io.vertx.rxjava.core.cli.CLI.newInstance(delegate.cli()); return ret; }
/** * Create a new process with empty arguments. * @return the process */ public io.vertx.rxjava.ext.shell.system.Process createProcess() { io.vertx.rxjava.ext.shell.system.Process ret = io.vertx.rxjava.ext.shell.system.Process.newInstance(delegate.createProcess()); return ret; }
/** * @return the command name */ public String name() { String ret = delegate.name(); return ret; }
@Override public List<Command> commands() { return baseCommandClasses(). stream(). map(clazz -> Command.create(vertx, clazz)). collect(Collectors.toList()); } }
@Override public void complete(Completion completion) { if (completeHandler != null) { context.runOnContext(v -> { try { completeHandler.handle(completion); } catch (Throwable t) { completion.complete(Collections.emptyList()); throw t; } }); } else { Command.super.complete(completion); } } };
if (commandContext.cli() != null) { if (commandContext.cli().parse(args2, false).isAskingForHelp()) { StringBuilder usage = new StringBuilder(); commandContext.cli().usage(usage); usage.append('\n'); tty.write(usage.toString()); cl = commandContext.cli().parse(args2); } catch (CLIException e) { tty.write(e.getMessage() + "\n");
/** * Create a new process with empty arguments. * @return the process */ public io.vertx.rxjava.ext.shell.system.Process createProcess() { io.vertx.rxjava.ext.shell.system.Process ret = io.vertx.rxjava.ext.shell.system.Process.newInstance(delegate.createProcess()); return ret; }
/** * Returns a single command by its name. * * @param name the command name * @return the commad or null */ default Command getCommand(String name) { return commands().stream().filter(cmd -> cmd.name().equals(name)).findFirst().orElse(null); } }
@Override public CommandRegistry registerCommand(Class<? extends AnnotatedCommand> command) { return registerCommand(Command.create(vertx, command)); }
@Override public void complete(Completion completion) { AnnotatedCommand instance; try { instance = clazz.newInstance(); } catch (Exception e) { Command.super.complete(completion); return; } context.runOnContext(v -> { try { instance.complete(completion); } catch (Throwable t) { completion.complete(Collections.emptyList()); throw t; } }); } };
/** * Create a new process with the passed arguments. * @param args the process arguments * @return the process */ public io.vertx.rxjava.ext.shell.system.Process createProcess(List<io.vertx.rxjava.ext.shell.cli.CliToken> args) { io.vertx.rxjava.ext.shell.system.Process ret = io.vertx.rxjava.ext.shell.system.Process.newInstance(delegate.createProcess(args.stream().map(elt -> elt.getDelegate()).collect(java.util.stream.Collectors.toList()))); return ret; }
@Override public void start() throws Exception { Map<String, CommandRegistration> newReg = new HashMap<>(); for (Command command : commands) { String name = command.name(); if (commandMap.containsKey(name)) { throw new Exception("Command " + name + " already registered"); } CommandRegistration registration = new CommandRegistration(command, deploymentID()); newReg.put(name, registration); } commandMap.putAll(newReg); }
@Override public CommandRegistry registerCommand(Class<? extends AnnotatedCommand> command, Handler<AsyncResult<Command>> completionHandler) { return registerCommand(Command.create(vertx, command), completionHandler); }
Command command = resolver.getCommand(ct.value()); if (command != null) { command.complete(new Completion() { @Override public Vertx vertx() {