Pluggable commands in the JShell tool
Andrei Eremeev
andrei.i.eremeev at mail.ru
Sat Mar 5 13:29:25 UTC 2016
Hi REPL team,
What do you think about pluggable commands in JShell? It will allow
users implementing their custom commands. For example, JShell can be
used in scripting, and it is useful to run a process within it. So, a
user can implement a command, like /run-process, and register it as a
service.
The commands can be loaded by ServiceLoader, and they should implement
an interface, like:
public interface Command {
boolean run(JShellWrapper jShell, String arg); // JShellWrapper is a class/interface which encapsulates JShellTool/JShellState
String command(); // command name
boolean matches(String input); // a method to understand whether the input typed by a user is the current command
String/List<String> parameters(); // information to be printed in the help command
String description(); // information to be printed in the help command
String help(); // information to be printed in the help command
CompletionProvider completionProvider(); // a provider to suggest completions for arguments of the command
}
What do you think?
Andrei
More information about the kulla-dev
mailing list