Pluggable commands in the JShell tool
Sundararajan Athijegannathan
sundararajan.athijegannathan at oracle.com
Mon Mar 7 03:41:12 UTC 2016
If that level of customization is needed, I think jjs tool can be used.
JShell Java API can be accessed from JavaScript and jjs provides
interactive shell with tab-completion, history etc. "commands" can be
just JS functions implemented in scripts loaded in the prompt or on
start-up.
-Sundar
On 3/7/2016 2:26 AM, Brian Goetz wrote:
> It’s a reasonable idea. (It would also be good if at least some of the commands supported by the shell tool could then use such a mechanism.) But I think its a bit much to think about for 9.
>
>> On Mar 5, 2016, at 8:29 AM, Andrei Eremeev <andrei.i.eremeev at mail.ru> wrote:
>>
>> 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