Fix: README

This commit is contained in:
anseki 2015-01-27 05:21:47 +09:00
parent 33653153dc
commit db8e754338
2 changed files with 36 additions and 32 deletions

View file

@ -32,46 +32,19 @@ npm install readline-sync
line = readlineSync.question([query[, options]]) line = readlineSync.question([query[, options]])
``` ```
Displays the `query` to the user, and then returns the user's response after it has been typed. Displays the `query` to the user, and then returns the user's response after it has been typed.
You can specify `options`. (see [Options](#options))
The `query` may be string, or may not be (e.g. number, Date, Object, etc.). This is converted to string (i.e. `toString` method is called) before it is displayed every time. The `query` may be string, or may not be (e.g. number, Date, Object, etc.). This is converted to string (i.e. `toString` method is called) before it is displayed every time.
#### noEchoBack
If `{noEchoBack: true}` is specified to `options`, echo back is avoided. It is used to hide the secret text (e.g. password) which is typed by user on screen.
For example:
```js
password = readlineSync.question('PASSWORD :', {noEchoBack: true});
console.log('Login ...');
```
The typed text is not shown on screen.
```shell
PASSWORD :
Login ...
```
#### noTrim
By default, the leading and trailing white spaces are removed from typed text. If `{noTrim: true}` is specified to `options`, those are not removed.
### prompt ### prompt
```js ```js
line = readlineSync.prompt([options]) line = readlineSync.prompt([options])
``` ```
Displays the current prompt (See `setPrompt` method) to the user, and then returns the user's response after it has been typed. Displays the current prompt (See `setPrompt` method) to the user, and then returns the user's response after it has been typed.
You can specify `options`. (see [Options](#options))
#### noEchoBack
If `{noEchoBack: true}` is specified to `options`, echo back is avoided. It is used to hide the secret text (e.g. password) which is typed by user on screen. (See `noEchoBack` option of `question` method)
#### noTrim
By default, the leading and trailing white spaces are removed from typed text. If `{noTrim: true}` is specified to `options`, those are not removed.
### setPrompt ### setPrompt
@ -133,6 +106,37 @@ readlineSync.setPrompt('> '.bold.red);
cmd = readlineSync.prompt(); cmd = readlineSync.prompt();
``` ```
## Options
An `options` Object can be specified to `prompt` method and `question` method. This Object can have following properties.
### noEchoBack
Type: Boolean
Default: `false`
If `true` is specified, echo back is avoided. It is used to hide the secret text (e.g. password) which is typed by user on screen.
For example:
```js
password = readlineSync.question('PASSWORD :', {noEchoBack: true});
console.log('Login ...');
```
The typed text is not shown on screen.
```shell
PASSWORD :
Login ...
```
### noTrim
Type: Boolean
Default: `false`
By default, the leading and trailing white spaces are removed from typed text. If `true` is specified, those are not removed.
## With Task Runner ## With Task Runner
The easy way to control the flow of task runner by the user's response: The easy way to control the flow of task runner by the user's response:

View file

@ -1,6 +1,6 @@
{ {
"name": "readline-sync", "name": "readline-sync",
"version": "0.5.1", "version": "0.5.2",
"title": "readlineSync", "title": "readlineSync",
"description": "Synchronous Readline", "description": "Synchronous Readline",
"keywords": [ "keywords": [