diff --git a/src/Node/ReadLine.js b/src/Node/ReadLine.js index 5a50cea..0647b95 100644 --- a/src/Node/ReadLine.js +++ b/src/Node/ReadLine.js @@ -31,6 +31,18 @@ exports.prompt = function (readline) { }; }; +exports.question = function(text) { + return function(callback) { + return function(readline) { + return function() { + readline.question(text, function(result) { + callback(result)(); + }); + }; + }; + }; +}; + exports.setPrompt = function (prompt) { return function (length) { return function (readline) { diff --git a/src/Node/ReadLine.purs b/src/Node/ReadLine.purs index 71110ef..0004681 100644 --- a/src/Node/ReadLine.purs +++ b/src/Node/ReadLine.purs @@ -17,6 +17,7 @@ module Node.ReadLine , setPrompt , setLineHandler , close + , question ) where import Prelude @@ -100,6 +101,16 @@ foreign import prompt . Interface -> Eff (readline :: READLINE | eff) Unit +-- | Writes a query to the output, waits +-- | for user input to be provided on input, then invokes +-- | the callback function +foreign import question + :: forall eff + . String + -> (String -> Eff (readline :: READLINE | eff) Unit) + -> Interface + -> Eff (readline :: READLINE | eff) Unit + -- | Set the prompt. foreign import setPrompt :: forall eff