Skip to content

Commit

Permalink
Hacked around REPL to add colors to the prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
davglass committed Feb 24, 2011
1 parent 32b0864 commit 1b0022c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
23 changes: 17 additions & 6 deletions bin/yui-repl.js
Expand Up @@ -9,7 +9,19 @@ require('colors');

var Y = require('yui3').silent().useSync('yui-base');

var repl = replServer.start('YUI@' + Y.version + '> ');
var prompt = 'YUI@' + Y.version + '> ';
var len = prompt.length;
prompt = 'YUI'.magenta + '@'.white + Y.version.yellow + '> '.white;

replServer.REPLServer.prototype.displayPrompt = function() {
var l = this.bufferedCommand.length ? 4 : len;
this.rli.setPrompt(this.bufferedCommand.length ? '... ' : this.prompt, l);
this.rli.prompt();
};

var repl = replServer.start(prompt);



var debug = false;

Expand All @@ -19,7 +31,7 @@ ctx.Y = Y;
repl.defineCommand('clear', {
help: 'Clear the current Y context',
action: function() {
this.outputStream.write('Resetting Y to the default state\n');
this.outputStream.write('Resetting Y to the default state\n'.magenta);
this.bufferedCommand = '';
this.context.Y = require('yui3').silent().useSync('yui-base');
this.displayPrompt();
Expand Down Expand Up @@ -154,7 +166,6 @@ repl.defineCommand('yql', {
}
});


process.on('uncaughtException', function(e) {
Y.log(e.stack, 'error', 'repl');
});
for (var i in repl.commands) {
repl.commands[i].help = repl.commands[i].help.white;
}
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "yui-repl",
"description": "YUI 3 Powered REPL",
"version": "0.0.3",
"version": "0.0.4",
"author": "Dav Glass <davglass@gmail.com>",
"bugs": { "web": "http://github.com/davglass/yui-repl/issues" },
"os": [ "darwin", "linux" ],
Expand Down

0 comments on commit 1b0022c

Please sign in to comment.