created: 20231116150029494 modified: 20231117043247159 module-type: command tags: title: $:/poc2go/modules/commands/repl.js type: application/javascript /*\ title: $:/poc2go/modules/commands/repl.js type: application/javascript module-type: command node.js REPL with access to $tw Optional params = REPL prompt \*/ (function(){ /*jslint node: true, browser: true */ /*global $tw: false */ "use strict"; exports.info = { name: "repl", synchronous: true }; var Command = function(params,commander,callback) { var self = this; this.params = params; this.commander = commander; this.callback = callback; }; Command.prototype.execute = function() { var self = this; // Only allow a single REPL instance if (!$tw.repl) { $tw.repl = new $tw.Repl(this.params.length ? this.params[0] : '$tw-repl> ') } // If REPL is reset (.clear) - context needs resetting $tw.repl.on('reset', function() { $tw.repl.context.$tw = $tw; }); // Initial context settings $tw.repl.context.$tw = $tw; return null; }; exports.Command = Command; })();