+ private static Console.Command modeCommand(String[] names, BiFunction<Console, String[], Mode> activate) {
+ return new Console.Command() {
+ @Override
+ public String[] getNames() {
+ return names;
+ }
+
+ @Override
+ public Object activate(Console console, String[] args) {
+ Mode mode = activate.apply(console, args);
+ if (mode == null) {
+ console.out("did NOT run command");
+ }
+ return mode;
+ }
+ };
+ }
+
+ static Console.Command help() {
+ return command(new String[] {"?", "h", "help"}, (console, args) -> {
+ for (Console.Command c : console.getCommands()) {
+ System.out.println(String.join("|", c.getNames()));
+ }
+ return true;
+ });
+ }
+