diff options
author | Evan Lucas <evanlucas@me.com> | 2016-06-02 20:31:23 -0500 |
---|---|---|
committer | Jeremiah Senkpiel <fishrock123@rocketmail.com> | 2016-07-05 22:14:53 +0200 |
commit | 6b1fc63dcb0cfab31347d2c92ff1c5be8397f6c8 (patch) | |
tree | c60cdd9381dcda423dbfb8a9b9a4ac4730e4d9c7 /doc | |
parent | e30f32f003a3a049ec0f62f71edbadc6f3ace7fe (diff) | |
download | node-new-6b1fc63dcb0cfab31347d2c92ff1c5be8397f6c8.tar.gz |
readline: allow passing prompt to constructor
Previously, one would have to call setPrompt after calling
rl.createInterface. Now, the prompt string can be set by passing the
prompt property.
PR-URL: https://github.com/nodejs/node/pull/7125
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Conflicts:
test/parallel/test-readline-interface.js
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/readline.md | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/doc/api/readline.md b/doc/api/readline.md index 448b109e4d..3855409083 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -357,6 +357,7 @@ added: v0.1.98 the history set this value to `0`. Defaults to `30`. This option makes sense only if `terminal` is set to `true` by the user or by an internal `output` check, otherwise the history caching mechanism is not initialized at all. + * `prompt` - the prompt string to use. Default: `'> '` The `readline.createInterface()` method creates a new `readline.Interface` instance. @@ -467,9 +468,12 @@ implement a small command-line interface: ```js const readline = require('readline'); -const rl = readline.createInterface(process.stdin, process.stdout); +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + prompt: 'OHAI> ' +}); -rl.setPrompt('OHAI> '); rl.prompt(); rl.on('line', (line) => { |