From 3723b08d1ff2b87c51e9595398e9c214f498f748 Mon Sep 17 00:00:00 2001 From: icebaker Date: Sat, 27 May 2023 12:40:53 -0300 Subject: improving repl apis --- controllers/instance.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'controllers/instance.rb') diff --git a/controllers/instance.rb b/controllers/instance.rb index fbe2348..a982261 100644 --- a/controllers/instance.rb +++ b/controllers/instance.rb @@ -31,10 +31,24 @@ module NanoBot @session.state end - def eval(input, &block) + def boot(as: 'eval', &block) @stream.callback = block if block && @stream.is_a?(Components::Stream) - Interfaces::Eval.evaluate(input, @cartridge, @session) + Interfaces::REPL.boot(@cartridge, @session, as:) + + return unless @stream.is_a?(Components::Stream) + + @stream.finish + end + + def prompt + Interfaces::REPL.prompt(@cartridge) + end + + def eval(input, as: 'eval', &block) + @stream.callback = block if block && @stream.is_a?(Components::Stream) + + Interfaces::Eval.evaluate(input, @cartridge, @session, as) return unless @stream.is_a?(Components::Stream) -- cgit v1.2.3