Created
August 20, 2012 13:47
-
-
Save linhuiw/3404203 to your computer and use it in GitHub Desktop.
Revisions
-
linhuiw created this gist
Aug 20, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ // // Based on github.com/cloudhead/http-console // An attempt at a simplified readline example. // var readline = require('readline') , util = require('util') , rl = readline.createInterface(process.stdin, process.stdout, completer) // This should work now, thanks to @josher19 function completer(line) { var completions = '.help .error .exit .quit .q'.split(' ') var hits = completions.filter(function(c) { if (c.indexOf(line) == 0) { // console.log('bang! ' + c); return c; } }); return [hits && hits.length ? hits : completions, line]; } rl.write('type your tab key!'); // Simulate ctrl+u to delete the line written previously //rl.write(null, {ctrl: true, name: 'u'});