Created
August 20, 2012 13:47
-
-
Save linhuiw/3404203 to your computer and use it in GitHub Desktop.
redline-complete
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 characters
// | |
// 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'}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment