Fix: README
This commit is contained in:
parent
cbd3b73c7d
commit
cac20d6540
2 changed files with 96 additions and 96 deletions
|
@ -7,8 +7,8 @@ The following methods and options are deprecated.
|
||||||
|
|
||||||
### <a name="deprecated_methods_and_options-setprint_method"></a>`setPrint` method
|
### <a name="deprecated_methods_and_options-setprint_method"></a>`setPrint` method
|
||||||
|
|
||||||
Use the [`print`](#basic_options-print) option.
|
Use the [`print`](README.md#basic_options-print) option.
|
||||||
For the [Default Options](#basic_options), use:
|
For the [Default Options](README.md#basic_options), use:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
readlineSync.setDefaultOptions({print: value});
|
readlineSync.setDefaultOptions({print: value});
|
||||||
|
@ -22,8 +22,8 @@ readlineSync.setPrint(value);
|
||||||
|
|
||||||
### <a name="deprecated_methods_and_options-setprompt_method"></a>`setPrompt` method
|
### <a name="deprecated_methods_and_options-setprompt_method"></a>`setPrompt` method
|
||||||
|
|
||||||
Use the [`prompt`](#basic_options-prompt) option.
|
Use the [`prompt`](README.md#basic_options-prompt) option.
|
||||||
For the [Default Options](#basic_options), use:
|
For the [Default Options](README.md#basic_options), use:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
readlineSync.setDefaultOptions({prompt: value});
|
readlineSync.setDefaultOptions({prompt: value});
|
||||||
|
@ -37,8 +37,8 @@ readlineSync.setPrompt(value);
|
||||||
|
|
||||||
### <a name="deprecated_methods_and_options-setencoding_method"></a>`setEncoding` method
|
### <a name="deprecated_methods_and_options-setencoding_method"></a>`setEncoding` method
|
||||||
|
|
||||||
Use the [`encoding`](#basic_options-encoding) option.
|
Use the [`encoding`](README.md#basic_options-encoding) option.
|
||||||
For the [Default Options](#basic_options), use:
|
For the [Default Options](README.md#basic_options), use:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
readlineSync.setDefaultOptions({encoding: value});
|
readlineSync.setDefaultOptions({encoding: value});
|
||||||
|
@ -52,8 +52,8 @@ readlineSync.setEncoding(value);
|
||||||
|
|
||||||
### <a name="deprecated_methods_and_options-setmask_method"></a>`setMask` method
|
### <a name="deprecated_methods_and_options-setmask_method"></a>`setMask` method
|
||||||
|
|
||||||
Use the [`mask`](#basic_options-mask) option.
|
Use the [`mask`](README.md#basic_options-mask) option.
|
||||||
For the [Default Options](#basic_options), use:
|
For the [Default Options](README.md#basic_options), use:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
readlineSync.setDefaultOptions({mask: value});
|
readlineSync.setDefaultOptions({mask: value});
|
||||||
|
@ -67,8 +67,8 @@ readlineSync.setMask(value);
|
||||||
|
|
||||||
### <a name="deprecated_methods_and_options-setbuffersize_method"></a>`setBufferSize` method
|
### <a name="deprecated_methods_and_options-setbuffersize_method"></a>`setBufferSize` method
|
||||||
|
|
||||||
Use the [`bufferSize`](#basic_options-buffersize) option.
|
Use the [`bufferSize`](README.md#basic_options-buffersize) option.
|
||||||
For the [Default Options](#basic_options), use:
|
For the [Default Options](README.md#basic_options), use:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
readlineSync.setDefaultOptions({bufferSize: value});
|
readlineSync.setDefaultOptions({bufferSize: value});
|
||||||
|
@ -82,8 +82,8 @@ readlineSync.setBufferSize(value);
|
||||||
|
|
||||||
### <a name="deprecated_methods_and_options-noechoback_option"></a>`noEchoBack` option
|
### <a name="deprecated_methods_and_options-noechoback_option"></a>`noEchoBack` option
|
||||||
|
|
||||||
Use [`hideEchoBack`](#basic_options-hideechoback) option instead of it.
|
Use [`hideEchoBack`](README.md#basic_options-hideechoback) option instead of it.
|
||||||
|
|
||||||
### <a name="deprecated_methods_and_options-notrim_option"></a>`noTrim` option
|
### <a name="deprecated_methods_and_options-notrim_option"></a>`noTrim` option
|
||||||
|
|
||||||
Use [`keepWhitespace`](#basic_options-keepwhitespace) option instead of it.
|
Use [`keepWhitespace`](README.md#basic_options-keepwhitespace) option instead of it.
|
||||||
|
|
168
README.md
168
README.md
|
@ -92,17 +92,17 @@ console.log('\nA value the user requested: ' + value);
|
||||||
A value the user requested: 51
|
A value the user requested: 51
|
||||||
```
|
```
|
||||||
|
|
||||||
## Installation<a name="installation"> </a>
|
## <a name="installation"></a>Installation
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
npm install readline-sync
|
npm install readline-sync
|
||||||
```
|
```
|
||||||
|
|
||||||
## Basic Methods<a name="basic_methods"> </a>
|
## <a name="basic_methods"></a>Basic Methods
|
||||||
|
|
||||||
These are used to control details of the behavior. It is recommended to use the [Utility Methods](#utility_methods) instead of Basic Methods if it satisfy your request.
|
These are used to control details of the behavior. It is recommended to use the [Utility Methods](#utility_methods) instead of Basic Methods if it satisfy your request.
|
||||||
|
|
||||||
### `question`<a name="basic_methods-question"> </a>
|
### <a name="basic_methods-question"></a>`question`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
answer = readlineSync.question([query[, options]])
|
answer = readlineSync.question([query[, options]])
|
||||||
|
@ -122,7 +122,7 @@ program = readlineSync.question('Which program starts do you want? :', {
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### `prompt`<a name="basic_methods-prompt"> </a>
|
### <a name="basic_methods-prompt"></a>`prompt`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
input = readlineSync.prompt([options])
|
input = readlineSync.prompt([options])
|
||||||
|
@ -140,7 +140,7 @@ while (true) {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### `keyIn`<a name="basic_methods-keyin"> </a>
|
### <a name="basic_methods-keyin"></a>`keyIn`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
pressedKey = readlineSync.keyIn([query[, options]])
|
pressedKey = readlineSync.keyIn([query[, options]])
|
||||||
|
@ -157,7 +157,7 @@ For example:
|
||||||
menuId = readlineSync.keyIn('Hit 1...5 key :', {limit: '${1-5}'});
|
menuId = readlineSync.keyIn('Hit 1...5 key :', {limit: '${1-5}'});
|
||||||
```
|
```
|
||||||
|
|
||||||
### `setDefaultOptions`<a name="basic_methods-setdefaultoptions"> </a>
|
### <a name="basic_methods-setdefaultoptions"></a>`setDefaultOptions`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
currentDefaultOptions = readlineSync.setDefaultOptions([newDefaultOptions])
|
currentDefaultOptions = readlineSync.setDefaultOptions([newDefaultOptions])
|
||||||
|
@ -166,7 +166,7 @@ currentDefaultOptions = readlineSync.setDefaultOptions([newDefaultOptions])
|
||||||
Change the [Default Options](#basic_options) to the values of properties of `newDefaultOptions` Object.
|
Change the [Default Options](#basic_options) to the values of properties of `newDefaultOptions` Object.
|
||||||
All it takes is to specify options that you want change, because unspecified options are not updated.
|
All it takes is to specify options that you want change, because unspecified options are not updated.
|
||||||
|
|
||||||
## Basic Options<a name="basic_options"> </a>
|
## <a name="basic_options"></a>Basic Options
|
||||||
|
|
||||||
[`prompt`](#basic_options-prompt), [`hideEchoBack`](#basic_options-hideechoback), [`mask`](#basic_options-mask), [`limit`](#basic_options-limit), [`limitMessage`](#basic_options-limitmessage), [`defaultInput`](#basic_options-defaultinput), [`trueValue`, `falseValue`](#basic_options-truevalue_falsevalue), [`caseSensitive`](#basic_options-casesensitive), [`keepWhitespace`](#basic_options-keepwhitespace), [`encoding`](#basic_options-encoding), [`bufferSize`](#basic_options-buffersize), [`print`](#basic_options-print), [`history`](#basic_options-history), [`cd`](#basic_options-cd)
|
[`prompt`](#basic_options-prompt), [`hideEchoBack`](#basic_options-hideechoback), [`mask`](#basic_options-mask), [`limit`](#basic_options-limit), [`limitMessage`](#basic_options-limitmessage), [`defaultInput`](#basic_options-defaultinput), [`trueValue`, `falseValue`](#basic_options-truevalue_falsevalue), [`caseSensitive`](#basic_options-casesensitive), [`keepWhitespace`](#basic_options-keepwhitespace), [`encoding`](#basic_options-encoding), [`bufferSize`](#basic_options-buffersize), [`print`](#basic_options-print), [`history`](#basic_options-history), [`cd`](#basic_options-cd)
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ a6 = readlineSync.question('And you? :'); // It's limited to 2 th
|
||||||
|
|
||||||
The Object as `options` can have following properties.
|
The Object as `options` can have following properties.
|
||||||
|
|
||||||
### `prompt`<a name="basic_options-prompt"> </a>
|
### <a name="basic_options-prompt"></a>`prompt`
|
||||||
|
|
||||||
_For `prompt*` methods only_
|
_For `prompt*` methods only_
|
||||||
*Type:* string or others
|
*Type:* string or others
|
||||||
|
@ -216,7 +216,7 @@ readlineSync.setDefaultOptions({
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### `hideEchoBack`<a name="basic_options-hideechoback"> </a>
|
### <a name="basic_options-hideechoback"></a>`hideEchoBack`
|
||||||
|
|
||||||
*Type:* boolean
|
*Type:* boolean
|
||||||
*Default:* `false`
|
*Default:* `false`
|
||||||
|
@ -235,7 +235,7 @@ PASSWORD :********
|
||||||
Login ...
|
Login ...
|
||||||
```
|
```
|
||||||
|
|
||||||
### `mask`<a name="basic_options-mask"> </a>
|
### <a name="basic_options-mask"></a>`mask`
|
||||||
|
|
||||||
*Type:* string
|
*Type:* string
|
||||||
*Default:* `'*'`
|
*Default:* `'*'`
|
||||||
|
@ -254,12 +254,12 @@ secret = readlineSync.question('Please whisper sweet words :', {
|
||||||
|
|
||||||
![sample](cl_02.png)
|
![sample](cl_02.png)
|
||||||
|
|
||||||
### `limit`<a name="basic_options-limit"> </a>
|
### <a name="basic_options-limit"></a>`limit`
|
||||||
|
|
||||||
Limit the user's input.
|
Limit the user's input.
|
||||||
The usage differ depending on the method.
|
The usage differ depending on the method.
|
||||||
|
|
||||||
#### For `question*` and `prompt*` methods<a name="basic_options-limit-for_question_and_prompt_methods"> </a>
|
#### <a name="basic_options-limit-for_question_and_prompt_methods"></a>For `question*` and `prompt*` methods
|
||||||
|
|
||||||
*Type:* string, number, RegExp, function or Array
|
*Type:* string, number, RegExp, function or Array
|
||||||
*Default:* `[]`
|
*Default:* `[]`
|
||||||
|
@ -301,7 +301,7 @@ action = readlineSync.prompt({limit: availableActions});
|
||||||
// ** But `promptCL` method should be used instead of this. **
|
// ** But `promptCL` method should be used instead of this. **
|
||||||
```
|
```
|
||||||
|
|
||||||
#### For `keyIn*` method<a name="basic_options-limit-for_keyin_method"> </a>
|
#### <a name="basic_options-limit-for_keyin_method"></a>For `keyIn*` method
|
||||||
|
|
||||||
*Type:* string, number or Array
|
*Type:* string, number or Array
|
||||||
*Default:* `[]`
|
*Default:* `[]`
|
||||||
|
@ -323,7 +323,7 @@ dice = readlineSync.keyIn('Roll the dice, What will the result be? :',
|
||||||
{limit: '${1-6}'}); // range of '1' to '6'
|
{limit: '${1-6}'}); // range of '1' to '6'
|
||||||
```
|
```
|
||||||
|
|
||||||
### `limitMessage`<a name="basic_options-limitmessage"> </a>
|
### <a name="basic_options-limitmessage"></a>`limitMessage`
|
||||||
|
|
||||||
_For `question*` and `prompt*` methods only_
|
_For `question*` and `prompt*` methods only_
|
||||||
*Type:* string
|
*Type:* string
|
||||||
|
@ -341,7 +341,7 @@ file = readlineSync.question('Name of Text File :', {
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### `defaultInput`<a name="basic_options-defaultinput"> </a>
|
### <a name="basic_options-defaultinput"></a>`defaultInput`
|
||||||
|
|
||||||
_For `question*` and `prompt*` methods only_
|
_For `question*` and `prompt*` methods only_
|
||||||
*Type:* string
|
*Type:* string
|
||||||
|
@ -355,7 +355,7 @@ For example:
|
||||||
lang = readlineSync.question('Which language? :', {defaultInput: 'javascript'});
|
lang = readlineSync.question('Which language? :', {defaultInput: 'javascript'});
|
||||||
```
|
```
|
||||||
|
|
||||||
### `trueValue`, `falseValue`<a name="basic_options-truevalue_falsevalue"> </a>
|
### <a name="basic_options-truevalue_falsevalue"></a>`trueValue`, `falseValue`
|
||||||
|
|
||||||
*Type:* string, number, RegExp, function or Array
|
*Type:* string, number, RegExp, function or Array
|
||||||
*Default:* `[]`
|
*Default:* `[]`
|
||||||
|
@ -385,7 +385,7 @@ if (answer === true) {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### `caseSensitive`<a name="basic_options-casesensitive"> </a>
|
### <a name="basic_options-casesensitive"></a>`caseSensitive`
|
||||||
|
|
||||||
*Type:* boolean
|
*Type:* boolean
|
||||||
*Default:* `false`
|
*Default:* `false`
|
||||||
|
@ -393,7 +393,7 @@ if (answer === true) {
|
||||||
By default, the string comparisons is case-insensitive (i.e. `a` equals `A`). If `true` is specified, it is case-sensitive, the cases are not ignored (i.e. `a` is different from `A`).
|
By default, the string comparisons is case-insensitive (i.e. `a` equals `A`). If `true` is specified, it is case-sensitive, the cases are not ignored (i.e. `a` is different from `A`).
|
||||||
It affects: [`limit`](#basic_options-limit), [`trueValue`](#basic_options-truevalue_falsevalue), [`falseValue`](#basic_options-truevalue_falsevalue), some [placeholders](#placeholders), and some [Utility Methods](#utility_methods).
|
It affects: [`limit`](#basic_options-limit), [`trueValue`](#basic_options-truevalue_falsevalue), [`falseValue`](#basic_options-truevalue_falsevalue), some [placeholders](#placeholders), and some [Utility Methods](#utility_methods).
|
||||||
|
|
||||||
### `keepWhitespace`<a name="basic_options-keepwhitespace"> </a>
|
### <a name="basic_options-keepwhitespace"></a>`keepWhitespace`
|
||||||
|
|
||||||
_For `question*` and `prompt*` methods only_
|
_For `question*` and `prompt*` methods only_
|
||||||
*Type:* boolean
|
*Type:* boolean
|
||||||
|
@ -401,14 +401,14 @@ _For `question*` and `prompt*` methods only_
|
||||||
|
|
||||||
By default, remove the leading and trailing white spaces from the input text. If `true` is specified, don't remove those.
|
By default, remove the leading and trailing white spaces from the input text. If `true` is specified, don't remove those.
|
||||||
|
|
||||||
### `encoding`<a name="basic_options-encoding"> </a>
|
### <a name="basic_options-encoding"></a>`encoding`
|
||||||
|
|
||||||
*Type:* string
|
*Type:* string
|
||||||
*Default:* `'utf8'`
|
*Default:* `'utf8'`
|
||||||
|
|
||||||
Set the encoding method of the input and output.
|
Set the encoding method of the input and output.
|
||||||
|
|
||||||
### `bufferSize`<a name="basic_options-buffersize"> </a>
|
### <a name="basic_options-buffersize"></a>`bufferSize`
|
||||||
|
|
||||||
*Type:* number
|
*Type:* number
|
||||||
*Default:* `1024`
|
*Default:* `1024`
|
||||||
|
@ -416,7 +416,7 @@ Set the encoding method of the input and output.
|
||||||
When readlineSync reads from a console directly (without external program), use a size `bufferSize` buffer.
|
When readlineSync reads from a console directly (without external program), use a size `bufferSize` buffer.
|
||||||
Even if the input by user exceeds it, it's usually no problem, because the buffer is used repeatedly. But some platforms's (e.g. Windows) console might not accept input that exceeds it. And set an enough size.
|
Even if the input by user exceeds it, it's usually no problem, because the buffer is used repeatedly. But some platforms's (e.g. Windows) console might not accept input that exceeds it. And set an enough size.
|
||||||
|
|
||||||
### `print`<a name="basic_options-print"> </a>
|
### <a name="basic_options-print"></a>`print`
|
||||||
|
|
||||||
*Type:* function or `undefined`
|
*Type:* function or `undefined`
|
||||||
*Default:* `undefined`
|
*Default:* `undefined`
|
||||||
|
@ -492,7 +492,7 @@ May I have your name? :Oz
|
||||||
Hi Oz! Where do you live? :Emerald City
|
Hi Oz! Where do you live? :Emerald City
|
||||||
```
|
```
|
||||||
|
|
||||||
### `history`<a name="basic_options-history"> </a>
|
### <a name="basic_options-history"></a>`history`
|
||||||
|
|
||||||
_For `question*` and `prompt*` methods only_
|
_For `question*` and `prompt*` methods only_
|
||||||
*Type:* boolean
|
*Type:* boolean
|
||||||
|
@ -525,7 +525,7 @@ hello
|
||||||
-- You said "bye"
|
-- You said "bye"
|
||||||
```
|
```
|
||||||
|
|
||||||
### `cd`<a name="basic_options-cd"> </a>
|
### <a name="basic_options-cd"></a>`cd`
|
||||||
|
|
||||||
_For `question*` and `prompt*` methods only_
|
_For `question*` and `prompt*` methods only_
|
||||||
*Type:* boolean
|
*Type:* boolean
|
||||||
|
@ -561,13 +561,13 @@ File :file-c.html
|
||||||
-- Specified file is /path/to/foo-dir/bar-dir/file-c.html
|
-- Specified file is /path/to/foo-dir/bar-dir/file-c.html
|
||||||
```
|
```
|
||||||
|
|
||||||
## Utility Methods<a name="utility_methods"> </a>
|
## <a name="utility_methods"></a>Utility Methods
|
||||||
|
|
||||||
[`questionEMail`](#utility_methods-questionemail), [`questionNewPassword`](#utility_methods-questionnewpassword), [`questionInt`](#utility_methods-questionint), [`questionFloat`](#utility_methods-questionfloat), [`questionPath`](#utility_methods-questionpath), [`promptCL`](#utility_methods-promptcl), [`promptLoop`](#utility_methods-promptloop), [`promptCLLoop`](#utility_methods-promptclloop), [`promptSimShell`](#utility_methods-promptsimshell), [`keyInYN`](#utility_methods-keyinyn), [`keyInYNStrict`](#utility_methods-keyinynstrict), [`keyInPause`](#utility_methods-keyinpause), [`keyInSelect`](#utility_methods-keyinselect)
|
[`questionEMail`](#utility_methods-questionemail), [`questionNewPassword`](#utility_methods-questionnewpassword), [`questionInt`](#utility_methods-questionint), [`questionFloat`](#utility_methods-questionfloat), [`questionPath`](#utility_methods-questionpath), [`promptCL`](#utility_methods-promptcl), [`promptLoop`](#utility_methods-promptloop), [`promptCLLoop`](#utility_methods-promptclloop), [`promptSimShell`](#utility_methods-promptsimshell), [`keyInYN`](#utility_methods-keyinyn), [`keyInYNStrict`](#utility_methods-keyinynstrict), [`keyInPause`](#utility_methods-keyinpause), [`keyInSelect`](#utility_methods-keyinselect)
|
||||||
|
|
||||||
These are convenient methods that are extended [Basic Methods](#basic_methods) to be used easily.
|
These are convenient methods that are extended [Basic Methods](#basic_methods) to be used easily.
|
||||||
|
|
||||||
### `questionEMail`<a name="utility_methods-questionemail"> </a>
|
### <a name="utility_methods-questionemail"></a>`questionEMail`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
email = readlineSync.questionEMail([query[, options]])
|
email = readlineSync.questionEMail([query[, options]])
|
||||||
|
@ -594,7 +594,7 @@ Input e-mail address :mail@example.com
|
||||||
-- E-mail is mail@example.com
|
-- E-mail is mail@example.com
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Options<a name="utility_methods-questionemail-options"> </a>
|
#### <a name="utility_methods-questionemail-options"></a>Options
|
||||||
|
|
||||||
The following options have independent default value that is not affected by [Default Options](#basic_options).
|
The following options have independent default value that is not affected by [Default Options](#basic_options).
|
||||||
|
|
||||||
|
@ -613,7 +613,7 @@ The following options work as shown in the [Basic Options](#basic_options) secti
|
||||||
<tr><td><a href="#basic_options-print"><code>print</code></a></td><td><a href="#basic_options-history"><code>history</code></a></td></tr>
|
<tr><td><a href="#basic_options-print"><code>print</code></a></td><td><a href="#basic_options-history"><code>history</code></a></td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
### `questionNewPassword`<a name="utility_methods-questionnewpassword"> </a>
|
### <a name="utility_methods-questionnewpassword"></a>`questionNewPassword`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
password = readlineSync.questionNewPassword([query[, options]])
|
password = readlineSync.questionNewPassword([query[, options]])
|
||||||
|
@ -646,7 +646,7 @@ Reinput a same one to confirm it :*************
|
||||||
-- Password is _my_password_
|
-- Password is _my_password_
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Options<a name="utility_methods-questionnewpassword-options"> </a>
|
#### <a name="utility_methods-questionnewpassword-options"></a>Options
|
||||||
|
|
||||||
The following options have independent default value that is not affected by [Default Options](#basic_options).
|
The following options have independent default value that is not affected by [Default Options](#basic_options).
|
||||||
|
|
||||||
|
@ -667,7 +667,7 @@ The following options work as shown in the [Basic Options](#basic_options) secti
|
||||||
|
|
||||||
And the following additional options are available.
|
And the following additional options are available.
|
||||||
|
|
||||||
##### `charlist`<a name="utility_methods-questionnewpassword-options-charlist"> </a>
|
##### <a name="utility_methods-questionnewpassword-options-charlist"></a>`charlist`
|
||||||
|
|
||||||
*Type:* string
|
*Type:* string
|
||||||
*Default:* `'${!-~}'`
|
*Default:* `'${!-~}'`
|
||||||
|
@ -681,7 +681,7 @@ For example, let the user input a password that is created with alphabet and som
|
||||||
password = readlineSync.questionNewPassword('PASSWORD :', {charlist: '${a-z}#$@%'});
|
password = readlineSync.questionNewPassword('PASSWORD :', {charlist: '${a-z}#$@%'});
|
||||||
```
|
```
|
||||||
|
|
||||||
##### `min`, `max`<a name="utility_methods-questionnewpassword-options-min_max"> </a>
|
##### <a name="utility_methods-questionnewpassword-options-min_max"></a>`min`, `max`
|
||||||
|
|
||||||
*Type:* number
|
*Type:* number
|
||||||
*Default:* `min`: `12`, `max`: `24`
|
*Default:* `min`: `12`, `max`: `24`
|
||||||
|
@ -689,7 +689,7 @@ password = readlineSync.questionNewPassword('PASSWORD :', {charlist: '${a-z}#$@%
|
||||||
`min`: A number as a minimum length of the password.
|
`min`: A number as a minimum length of the password.
|
||||||
`max`: A number as a maximum length of the password.
|
`max`: A number as a maximum length of the password.
|
||||||
|
|
||||||
##### `confirmMessage`<a name="utility_methods-questionnewpassword-options-confirmmessage"> </a>
|
##### <a name="utility_methods-questionnewpassword-options-confirmmessage"></a>`confirmMessage`
|
||||||
|
|
||||||
*Type:* string or others
|
*Type:* string or others
|
||||||
*Default:* `'Reinput a same one to confirm it :'`
|
*Default:* `'Reinput a same one to confirm it :'`
|
||||||
|
@ -698,7 +698,7 @@ A message that lets the user input the same password again.
|
||||||
It can include the [placeholders](#placeholders).
|
It can include the [placeholders](#placeholders).
|
||||||
If this is not string, it is converted to string (i.e. `toString` method is called).
|
If this is not string, it is converted to string (i.e. `toString` method is called).
|
||||||
|
|
||||||
##### `unmatchMessage`<a name="utility_methods-questionnewpassword-options-unmatchmessage"> </a>
|
##### <a name="utility_methods-questionnewpassword-options-unmatchmessage"></a>`unmatchMessage`
|
||||||
|
|
||||||
*Type:* string or others
|
*Type:* string or others
|
||||||
*Default:* `'It differs from first one. Hit only Enter key if you want to retry from first one.'`
|
*Default:* `'It differs from first one. Hit only Enter key if you want to retry from first one.'`
|
||||||
|
@ -706,19 +706,19 @@ If this is not string, it is converted to string (i.e. `toString` method is call
|
||||||
A warning message that is displayed when the second input did not match first one.
|
A warning message that is displayed when the second input did not match first one.
|
||||||
This is converted the same as the [`confirmMessage`](#utility_methods-questionnewpassword-options-confirmmessage) option.
|
This is converted the same as the [`confirmMessage`](#utility_methods-questionnewpassword-options-confirmmessage) option.
|
||||||
|
|
||||||
#### Additional Placeholders<a name="utility_methods-questionnewpassword-additional_placeholders"> </a>
|
#### <a name="utility_methods-questionnewpassword-additional_placeholders"></a>Additional Placeholders
|
||||||
|
|
||||||
The following additional [placeholder](#placeholders) parameters are available.
|
The following additional [placeholder](#placeholders) parameters are available.
|
||||||
|
|
||||||
##### `charlist`<a name="utility_methods-questionnewpassword-additional_placeholders-charlist"> </a>
|
##### <a name="utility_methods-questionnewpassword-additional_placeholders-charlist"></a>`charlist`
|
||||||
|
|
||||||
A current value of [`charlist`](#utility_methods-questionnewpassword-options-charlist) option that is converted to human readable if possible. (e.g. `'A...Z'`)
|
A current value of [`charlist`](#utility_methods-questionnewpassword-options-charlist) option that is converted to human readable if possible. (e.g. `'A...Z'`)
|
||||||
|
|
||||||
##### `length`<a name="utility_methods-questionnewpassword-additional_placeholders-length"> </a>
|
##### <a name="utility_methods-questionnewpassword-additional_placeholders-length"></a>`length`
|
||||||
|
|
||||||
A current value of [`min` and `max`](#utility_methods-questionnewpassword-options-min_max) option that is converted to human readable. (e.g. `'12...24'`)
|
A current value of [`min` and `max`](#utility_methods-questionnewpassword-options-min_max) option that is converted to human readable. (e.g. `'12...24'`)
|
||||||
|
|
||||||
### `questionInt`<a name="utility_methods-questionint"> </a>
|
### <a name="utility_methods-questionint"></a>`questionInt`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
numInt = readlineSync.questionInt([query[, options]])
|
numInt = readlineSync.questionInt([query[, options]])
|
||||||
|
@ -729,7 +729,7 @@ This parses the input as much as possible by `parseInt()`. For example, it inter
|
||||||
|
|
||||||
The `query` is handled the same as that of the [`question`](#basic_methods-question) method.
|
The `query` is handled the same as that of the [`question`](#basic_methods-question) method.
|
||||||
|
|
||||||
#### Options<a name="utility_methods-questionint-options"> </a>
|
#### <a name="utility_methods-questionint-options"></a>Options
|
||||||
|
|
||||||
The following option has independent default value that is not affected by [Default Options](#basic_options).
|
The following option has independent default value that is not affected by [Default Options](#basic_options).
|
||||||
|
|
||||||
|
@ -744,7 +744,7 @@ The following options work as shown in the [Basic Options](#basic_options) secti
|
||||||
<tr><td><a href="#basic_options-encoding"><code>encoding</code></a></td><td><a href="#basic_options-buffersize"><code>bufferSize</code></a></td><td><a href="#basic_options-print"><code>print</code></a></td><td><a href="#basic_options-history"><code>history</code></a></td></tr>
|
<tr><td><a href="#basic_options-encoding"><code>encoding</code></a></td><td><a href="#basic_options-buffersize"><code>bufferSize</code></a></td><td><a href="#basic_options-print"><code>print</code></a></td><td><a href="#basic_options-history"><code>history</code></a></td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
### `questionFloat`<a name="utility_methods-questionfloat"> </a>
|
### <a name="utility_methods-questionfloat"></a>`questionFloat`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
numFloat = readlineSync.questionFloat([query[, options]])
|
numFloat = readlineSync.questionFloat([query[, options]])
|
||||||
|
@ -755,7 +755,7 @@ This parses the input as much as possible by `parseFloat()`. For example, it int
|
||||||
|
|
||||||
The `query` is handled the same as that of the [`question`](#basic_methods-question) method.
|
The `query` is handled the same as that of the [`question`](#basic_methods-question) method.
|
||||||
|
|
||||||
#### Options<a name="utility_methods-questionfloat-options"> </a>
|
#### <a name="utility_methods-questionfloat-options"></a>Options
|
||||||
|
|
||||||
The following option has independent default value that is not affected by [Default Options](#basic_options).
|
The following option has independent default value that is not affected by [Default Options](#basic_options).
|
||||||
|
|
||||||
|
@ -770,7 +770,7 @@ The following options work as shown in the [Basic Options](#basic_options) secti
|
||||||
<tr><td><a href="#basic_options-encoding"><code>encoding</code></a></td><td><a href="#basic_options-buffersize"><code>bufferSize</code></a></td><td><a href="#basic_options-print"><code>print</code></a></td><td><a href="#basic_options-history"><code>history</code></a></td></tr>
|
<tr><td><a href="#basic_options-encoding"><code>encoding</code></a></td><td><a href="#basic_options-buffersize"><code>bufferSize</code></a></td><td><a href="#basic_options-print"><code>print</code></a></td><td><a href="#basic_options-history"><code>history</code></a></td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
### `questionPath`<a name="utility_methods-questionpath"> </a>
|
### <a name="utility_methods-questionpath"></a>`questionPath`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
path = readlineSync.questionPath([query[, options]])
|
path = readlineSync.questionPath([query[, options]])
|
||||||
|
@ -814,7 +814,7 @@ Save to :~/deploy/data
|
||||||
-- saveDir: /home/user/deploy/data
|
-- saveDir: /home/user/deploy/data
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Options<a name="utility_methods-questionpath-options"> </a>
|
#### <a name="utility_methods-questionpath-options"></a>Options
|
||||||
|
|
||||||
The following options have independent default value that is not affected by [Default Options](#basic_options).
|
The following options have independent default value that is not affected by [Default Options](#basic_options).
|
||||||
|
|
||||||
|
@ -836,7 +836,7 @@ And the following additional options are available.
|
||||||
|
|
||||||
*Note:* It does not check the coherency about a combination of the options as the path requirement. For example, the `{exists: false, isFile: true}` never check that it is a file because it is limited to the path that does not exist.
|
*Note:* It does not check the coherency about a combination of the options as the path requirement. For example, the `{exists: false, isFile: true}` never check that it is a file because it is limited to the path that does not exist.
|
||||||
|
|
||||||
##### `exists`<a name="utility_methods-questionpath-options-exists"> </a>
|
##### <a name="utility_methods-questionpath-options-exists"></a>`exists`
|
||||||
|
|
||||||
*Type:* boolean or others
|
*Type:* boolean or others
|
||||||
*Default:* `true`
|
*Default:* `true`
|
||||||
|
@ -844,7 +844,7 @@ And the following additional options are available.
|
||||||
If `true` is specified, accept only a file or directory path that exists. If `false` is specified, accept only a file or directory path that does *not* exist.
|
If `true` is specified, accept only a file or directory path that exists. If `false` is specified, accept only a file or directory path that does *not* exist.
|
||||||
In any other case, the existence is not checked.
|
In any other case, the existence is not checked.
|
||||||
|
|
||||||
##### `min`, `max`<a name="utility_methods-questionpath-options-min_max"> </a>
|
##### <a name="utility_methods-questionpath-options-min_max"></a>`min`, `max`
|
||||||
|
|
||||||
*Type:* number or others
|
*Type:* number or others
|
||||||
*Default:* `undefined`
|
*Default:* `undefined`
|
||||||
|
@ -853,7 +853,7 @@ In any other case, the existence is not checked.
|
||||||
`max`: A number as a maximum size of the file that is accepted.
|
`max`: A number as a maximum size of the file that is accepted.
|
||||||
If it is not specified or `0` is specified, the size is not checked. (A size of directory is `0`.)
|
If it is not specified or `0` is specified, the size is not checked. (A size of directory is `0`.)
|
||||||
|
|
||||||
##### `isFile`, `isDirectory`<a name="utility_methods-questionpath-options-isfile_isdirectory"> </a>
|
##### <a name="utility_methods-questionpath-options-isfile_isdirectory"></a>`isFile`, `isDirectory`
|
||||||
|
|
||||||
*Type:* boolean
|
*Type:* boolean
|
||||||
*Default:* `false`
|
*Default:* `false`
|
||||||
|
@ -861,7 +861,7 @@ If it is not specified or `0` is specified, the size is not checked. (A size of
|
||||||
`isFile`: If `true` is specified, accept only a file path.
|
`isFile`: If `true` is specified, accept only a file path.
|
||||||
`isDirectory`: If `true` is specified, accept only a directory path.
|
`isDirectory`: If `true` is specified, accept only a directory path.
|
||||||
|
|
||||||
##### `validate`<a name="utility_methods-questionpath-options-validate"> </a>
|
##### <a name="utility_methods-questionpath-options-validate"></a>`validate`
|
||||||
|
|
||||||
*Type:* function or `undefined`
|
*Type:* function or `undefined`
|
||||||
*Default:* `undefined`
|
*Default:* `undefined`
|
||||||
|
@ -879,7 +879,7 @@ imageFile = readlineSync.questionPath('Image File :', {
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
##### `create`<a name="utility_methods-questionpath-options-create"> </a>
|
##### <a name="utility_methods-questionpath-options-create"></a>`create`
|
||||||
|
|
||||||
*Type:* boolean
|
*Type:* boolean
|
||||||
*Default:* `false`
|
*Default:* `false`
|
||||||
|
@ -887,20 +887,20 @@ imageFile = readlineSync.questionPath('Image File :', {
|
||||||
If `true` is specified, create a file or directory as a path that was input when it doesn't exist. If `true` is specified to the [`isDirectory`](#utility_methods-questionpath-options-isfile_isdirectory) option, create a directory, otherwise a file.
|
If `true` is specified, create a file or directory as a path that was input when it doesn't exist. If `true` is specified to the [`isDirectory`](#utility_methods-questionpath-options-isfile_isdirectory) option, create a directory, otherwise a file.
|
||||||
It does not affect the existence check. Therefore, you can get a new file or directory path anytime by specifying: `{exists: false, create: true}`
|
It does not affect the existence check. Therefore, you can get a new file or directory path anytime by specifying: `{exists: false, create: true}`
|
||||||
|
|
||||||
#### Additional Placeholders<a name="utility_methods-questionpath-additional_placeholders"> </a>
|
#### <a name="utility_methods-questionpath-additional_placeholders"></a>Additional Placeholders
|
||||||
|
|
||||||
The following additional [placeholder](#placeholders) parameters are available.
|
The following additional [placeholder](#placeholders) parameters are available.
|
||||||
|
|
||||||
##### `error`<a name="utility_methods-questionpath-additional_placeholders-error"> </a>
|
##### <a name="utility_methods-questionpath-additional_placeholders-error"></a>`error`
|
||||||
|
|
||||||
An error message when the input was not accepted.
|
An error message when the input was not accepted.
|
||||||
This value is set by readlineSync, or the function that was specified to [`validate`](#utility_methods-questionpath-options-validate) option.
|
This value is set by readlineSync, or the function that was specified to [`validate`](#utility_methods-questionpath-options-validate) option.
|
||||||
|
|
||||||
##### `min`, `max`<a name="utility_methods-questionpath-additional_placeholders-min_max"> </a>
|
##### <a name="utility_methods-questionpath-additional_placeholders-min_max"></a>`min`, `max`
|
||||||
|
|
||||||
A current value of [`min` and `max`](#utility_methods-questionpath-options-min_max) option.
|
A current value of [`min` and `max`](#utility_methods-questionpath-options-min_max) option.
|
||||||
|
|
||||||
### `promptCL`<a name="utility_methods-promptcl"> </a>
|
### <a name="utility_methods-promptcl"></a>`promptCL`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
argsArray = readlineSync.promptCL([commandHandler[, options]])
|
argsArray = readlineSync.promptCL([commandHandler[, options]])
|
||||||
|
@ -928,7 +928,7 @@ arg
|
||||||
arg
|
arg
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `commandHandler`<a name="utility_methods-promptcl-commandhandler"> </a>
|
#### <a name="utility_methods-promptcl-commandhandler"></a>`commandHandler`
|
||||||
|
|
||||||
By using the `commandHandler` argument, this method will come into its own. Specifying the Object to this argument has the more merit. And it has the more merit for [`promptCLLoop`](#utility_methods-promptclloop) method.
|
By using the `commandHandler` argument, this method will come into its own. Specifying the Object to this argument has the more merit. And it has the more merit for [`promptCLLoop`](#utility_methods-promptclloop) method.
|
||||||
|
|
||||||
|
@ -999,7 +999,7 @@ readlineSync.promptCL({
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Options<a name="utility_methods-promptcl-options"> </a>
|
#### <a name="utility_methods-promptcl-options"></a>Options
|
||||||
|
|
||||||
The following options have independent default value that is not affected by [Default Options](#basic_options).
|
The following options have independent default value that is not affected by [Default Options](#basic_options).
|
||||||
|
|
||||||
|
@ -1017,7 +1017,7 @@ The following options work as shown in the [Basic Options](#basic_options) secti
|
||||||
<tr><td><a href="#basic_options-print"><code>print</code></a></td><td><a href="#basic_options-cd"><code>cd</code></a></td></tr>
|
<tr><td><a href="#basic_options-print"><code>print</code></a></td><td><a href="#basic_options-cd"><code>cd</code></a></td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
### `promptLoop`<a name="utility_methods-promptloop"> </a>
|
### <a name="utility_methods-promptloop"></a>`promptLoop`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
readlineSync.promptLoop(inputHandler[, options])
|
readlineSync.promptLoop(inputHandler[, options])
|
||||||
|
@ -1056,7 +1056,7 @@ console.log('It\'s exited from loop.');
|
||||||
It's exited from loop.
|
It's exited from loop.
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Options<a name="utility_methods-promptloop-options"> </a>
|
#### <a name="utility_methods-promptloop-options"></a>Options
|
||||||
|
|
||||||
The following options have independent default value that is not affected by [Default Options](#basic_options).
|
The following options have independent default value that is not affected by [Default Options](#basic_options).
|
||||||
|
|
||||||
|
@ -1070,7 +1070,7 @@ The following options have independent default value that is not affected by [De
|
||||||
|
|
||||||
The other options work as shown in the [Basic Options](#basic_options) section.
|
The other options work as shown in the [Basic Options](#basic_options) section.
|
||||||
|
|
||||||
### `promptCLLoop`<a name="utility_methods-promptclloop"> </a>
|
### <a name="utility_methods-promptclloop"></a>`promptCLLoop`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
readlineSync.promptCLLoop([commandHandler[, options]])
|
readlineSync.promptCLLoop([commandHandler[, options]])
|
||||||
|
@ -1118,7 +1118,7 @@ filesOnOld is copied to New Hard Disk.
|
||||||
It's exited from loop.
|
It's exited from loop.
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Options<a name="utility_methods-promptclloop-options"> </a>
|
#### <a name="utility_methods-promptclloop-options"></a>Options
|
||||||
|
|
||||||
The following options have independent default value that is not affected by [Default Options](#basic_options).
|
The following options have independent default value that is not affected by [Default Options](#basic_options).
|
||||||
|
|
||||||
|
@ -1136,7 +1136,7 @@ The following options work as shown in the [Basic Options](#basic_options) secti
|
||||||
<tr><td><a href="#basic_options-print"><code>print</code></a></td><td><a href="#basic_options-cd"><code>cd</code></a></td></tr>
|
<tr><td><a href="#basic_options-print"><code>print</code></a></td><td><a href="#basic_options-cd"><code>cd</code></a></td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
### `promptSimShell`<a name="utility_methods-promptsimshell"> </a>
|
### <a name="utility_methods-promptsimshell"></a>`promptSimShell`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
input = readlineSync.promptSimShell([options])
|
input = readlineSync.promptSimShell([options])
|
||||||
|
@ -1157,7 +1157,7 @@ On others:
|
||||||
user@host:~/path/to/directory$
|
user@host:~/path/to/directory$
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Options<a name="utility_methods-promptsimshell-options"> </a>
|
#### <a name="utility_methods-promptsimshell-options"></a>Options
|
||||||
|
|
||||||
The following options have independent default value that is not affected by [Default Options](#basic_options).
|
The following options have independent default value that is not affected by [Default Options](#basic_options).
|
||||||
|
|
||||||
|
@ -1168,7 +1168,7 @@ The following options have independent default value that is not affected by [De
|
||||||
|
|
||||||
The other options other than [`prompt`](#basic_options-prompt) option work as shown in the [Basic Options](#basic_options) section.
|
The other options other than [`prompt`](#basic_options-prompt) option work as shown in the [Basic Options](#basic_options) section.
|
||||||
|
|
||||||
### `keyInYN`<a name="utility_methods-keyinyn"> </a>
|
### <a name="utility_methods-keyinyn"></a>`keyInYN`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
boolYesOrEmpty = readlineSync.keyInYN([query[, options]])
|
boolYesOrEmpty = readlineSync.keyInYN([query[, options]])
|
||||||
|
@ -1209,7 +1209,7 @@ if (readlineSync.keyInYN('Continue virus scan?') === false) {
|
||||||
// Continue...
|
// Continue...
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Options<a name="utility_methods-keyinyn-options"> </a>
|
#### <a name="utility_methods-keyinyn-options"></a>Options
|
||||||
|
|
||||||
The following options work as shown in the [Basic Options](#basic_options) section.
|
The following options work as shown in the [Basic Options](#basic_options) section.
|
||||||
|
|
||||||
|
@ -1219,7 +1219,7 @@ The following options work as shown in the [Basic Options](#basic_options) secti
|
||||||
|
|
||||||
And the following additional option is available.
|
And the following additional option is available.
|
||||||
|
|
||||||
##### `guide`<a name="utility_methods-keyinyn-options-guide"> </a>
|
##### <a name="utility_methods-keyinyn-options-guide"></a>`guide`
|
||||||
|
|
||||||
*Type:* boolean
|
*Type:* boolean
|
||||||
*Default:* `true`
|
*Default:* `true`
|
||||||
|
@ -1238,7 +1238,7 @@ Do you like me? [y/n] :y
|
||||||
Really? [y/n] :y
|
Really? [y/n] :y
|
||||||
```
|
```
|
||||||
|
|
||||||
### `keyInYNStrict`<a name="utility_methods-keyinynstrict"> </a>
|
### <a name="utility_methods-keyinynstrict"></a>`keyInYNStrict`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
boolYes = readlineSync.keyInYNStrict([query[, options]])
|
boolYes = readlineSync.keyInYNStrict([query[, options]])
|
||||||
|
@ -1257,7 +1257,7 @@ A key other than `Y` and `N` is not accepted. That is, a return value has no def
|
||||||
|
|
||||||
This method works same to [`keyInYN`](#utility_methods-keyinyn) method except that this accept only `Y` or `N` key (Therefore, a return value is boolean every time). The options also work same to [`keyInYN`](#utility_methods-keyinyn) method.
|
This method works same to [`keyInYN`](#utility_methods-keyinyn) method except that this accept only `Y` or `N` key (Therefore, a return value is boolean every time). The options also work same to [`keyInYN`](#utility_methods-keyinyn) method.
|
||||||
|
|
||||||
### `keyInPause`<a name="utility_methods-keyinpause"> </a>
|
### <a name="utility_methods-keyinpause"></a>`keyInPause`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
readlineSync.keyInPause([query[, options]])
|
readlineSync.keyInPause([query[, options]])
|
||||||
|
@ -1289,7 +1289,7 @@ Continue... (Hit any key)
|
||||||
It's executing now...
|
It's executing now...
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Options<a name="utility_methods-keyinpause-options"> </a>
|
#### <a name="utility_methods-keyinpause-options"></a>Options
|
||||||
|
|
||||||
The following option has independent default value that is not affected by [Default Options](#basic_options).
|
The following option has independent default value that is not affected by [Default Options](#basic_options).
|
||||||
|
|
||||||
|
@ -1305,7 +1305,7 @@ The following options work as shown in the [Basic Options](#basic_options) secti
|
||||||
|
|
||||||
And the following additional option is available.
|
And the following additional option is available.
|
||||||
|
|
||||||
##### `guide`<a name="utility_methods-keyinpause-options-guide"> </a>
|
##### <a name="utility_methods-keyinpause-options-guide"></a>`guide`
|
||||||
|
|
||||||
*Type:* boolean
|
*Type:* boolean
|
||||||
*Default:* `true`
|
*Default:* `true`
|
||||||
|
@ -1322,7 +1322,7 @@ readlineSync.keyInPause('It\'s pausing now...');
|
||||||
It's pausing now... (Hit any key)
|
It's pausing now... (Hit any key)
|
||||||
```
|
```
|
||||||
|
|
||||||
### `keyInSelect`<a name="utility_methods-keyinselect"> </a>
|
### <a name="utility_methods-keyinselect"></a>`keyInSelect`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
index = readlineSync.keyInSelect(items[, query[, options]])
|
index = readlineSync.keyInSelect(items[, query[, options]])
|
||||||
|
@ -1355,7 +1355,7 @@ Which framework? [1...5 / 0] :2
|
||||||
hapi is enabled.
|
hapi is enabled.
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Options<a name="utility_methods-keyinselect-options"> </a>
|
#### <a name="utility_methods-keyinselect-options"></a>Options
|
||||||
|
|
||||||
The following option has independent default value that is not affected by [Default Options](#basic_options).
|
The following option has independent default value that is not affected by [Default Options](#basic_options).
|
||||||
|
|
||||||
|
@ -1371,21 +1371,21 @@ The following options work as shown in the [Basic Options](#basic_options) secti
|
||||||
|
|
||||||
And the following additional options are available.
|
And the following additional options are available.
|
||||||
|
|
||||||
##### `guide`<a name="utility_methods-keyinselect-options-guide"> </a>
|
##### <a name="utility_methods-keyinselect-options-guide"></a>`guide`
|
||||||
|
|
||||||
*Type:* boolean
|
*Type:* boolean
|
||||||
*Default:* `true`
|
*Default:* `true`
|
||||||
|
|
||||||
If `true` is specified, a string like `'[1...5]'` as guide for the user is added to `query`. And `':'` is moved to the end of `query`, or it is added. This is the key list that corresponds to the item list.
|
If `true` is specified, a string like `'[1...5]'` as guide for the user is added to `query`. And `':'` is moved to the end of `query`, or it is added. This is the key list that corresponds to the item list.
|
||||||
|
|
||||||
##### `cancel`<a name="utility_methods-keyinselect-options-cancel"> </a>
|
##### <a name="utility_methods-keyinselect-options-cancel"></a>`cancel`
|
||||||
|
|
||||||
*Type:* boolean
|
*Type:* boolean
|
||||||
*Default:* `true`
|
*Default:* `true`
|
||||||
|
|
||||||
If `true` is specified, an item to let the user tell "cancel" is added to the item list. "[0] CANCEL" is displayed, and if `0` key is pressed, `-1` is returned.
|
If `true` is specified, an item to let the user tell "cancel" is added to the item list. "[0] CANCEL" is displayed, and if `0` key is pressed, `-1` is returned.
|
||||||
|
|
||||||
## Placeholders<a name="placeholders"> </a>
|
## <a name="placeholders"></a>Placeholders
|
||||||
|
|
||||||
[`hideEchoBack`, `mask`, `defaultInput`, `caseSensitive`, `keepWhitespace`, `encoding`, `bufferSize`, `history`, `cd`, `limit`, `trueValue`, `falseValue`](#placeholders-parameters-hideechoback_mask_defaultinput_casesensitive_keepwhitespace_encoding_buffersize_history_cd_limit_truevalue_falsevalue), [`limitCount`, `limitCountNotZero`](#placeholders-parameters-limitcount_limitcountnotzero), [`lastInput`](#placeholders-parameters-lastinput), [`history_mN`](#placeholders-parameters-historymn), [`cwd`, `CWD`, `cwdHome`](#placeholders-parameters-cwd_cwd_cwdhome), [`date`, `time`, `localeDate`, `localeTime`](#placeholders-parameters-date_time_localedate_localetime), [`C1-C2`](#placeholders-parameters-c1_c2)
|
[`hideEchoBack`, `mask`, `defaultInput`, `caseSensitive`, `keepWhitespace`, `encoding`, `bufferSize`, `history`, `cd`, `limit`, `trueValue`, `falseValue`](#placeholders-parameters-hideechoback_mask_defaultinput_casesensitive_keepwhitespace_encoding_buffersize_history_cd_limit_truevalue_falsevalue), [`limitCount`, `limitCountNotZero`](#placeholders-parameters-limitcount_limitcountnotzero), [`lastInput`](#placeholders-parameters-lastinput), [`history_mN`](#placeholders-parameters-historymn), [`cwd`, `CWD`, `cwdHome`](#placeholders-parameters-cwd_cwd_cwdhome), [`date`, `time`, `localeDate`, `localeTime`](#placeholders-parameters-date_time_localedate_localetime), [`C1-C2`](#placeholders-parameters-c1_c2)
|
||||||
|
|
||||||
|
@ -1412,7 +1412,7 @@ The placeholders can be included in:
|
||||||
* [`limit` option for `keyIn*` method](#basic_options-limit-for_keyin_method) and [`charlist`](#utility_methods-questionnewpassword-options-charlist) option for [`questionNewPassword`](#utility_methods-questionnewpassword) method ([`C1-C2`](#placeholders-parameters-c1_c2) parameter only)
|
* [`limit` option for `keyIn*` method](#basic_options-limit-for_keyin_method) and [`charlist`](#utility_methods-questionnewpassword-options-charlist) option for [`questionNewPassword`](#utility_methods-questionnewpassword) method ([`C1-C2`](#placeholders-parameters-c1_c2) parameter only)
|
||||||
* And some additional options for the [Utility Methods](#utility_methods).
|
* And some additional options for the [Utility Methods](#utility_methods).
|
||||||
|
|
||||||
### Syntax<a name="placeholders-syntax"> </a>
|
### <a name="placeholders-syntax"></a>Syntax
|
||||||
|
|
||||||
```
|
```
|
||||||
${parameter}
|
${parameter}
|
||||||
|
@ -1468,11 +1468,11 @@ Refused . Please input another.
|
||||||
|
|
||||||
(May be more better: `'${(Refused )lastInput( you requested. )}Please input another.'`)
|
(May be more better: `'${(Refused )lastInput( you requested. )}Please input another.'`)
|
||||||
|
|
||||||
### Parameters<a name="placeholders-parameters"> </a>
|
### <a name="placeholders-parameters"></a>Parameters
|
||||||
|
|
||||||
The following parameters are available. And some additional parameters are available in the [Utility Methods](#utility_methods).
|
The following parameters are available. And some additional parameters are available in the [Utility Methods](#utility_methods).
|
||||||
|
|
||||||
#### <a name="placeholders-parameters-hideechoback_mask_defaultinput_casesensitive_keepwhitespace_encoding_buffersize_history_cd_limit_truevalue_falsevalue"> </a>`hideEchoBack`, `mask`, `defaultInput`, `caseSensitive`, `keepWhitespace`, `encoding`, `bufferSize`, `history`, `cd`, `limit`, `trueValue`, `falseValue`
|
#### <a name="placeholders-parameters-hideechoback_mask_defaultinput_casesensitive_keepwhitespace_encoding_buffersize_history_cd_limit_truevalue_falsevalue"></a>`hideEchoBack`, `mask`, `defaultInput`, `caseSensitive`, `keepWhitespace`, `encoding`, `bufferSize`, `history`, `cd`, `limit`, `trueValue`, `falseValue`
|
||||||
|
|
||||||
A current value of each option.
|
A current value of each option.
|
||||||
It is converted to human readable if possible. The boolean value is replaced to `'on'` or `'off'`, and the Array is replaced to the list of only string and number elements.
|
It is converted to human readable if possible. The boolean value is replaced to `'on'` or `'off'`, and the Array is replaced to the list of only string and number elements.
|
||||||
|
@ -1491,7 +1491,7 @@ input = readlineSync.question(
|
||||||
Input something or Enter key as "hello" :
|
Input something or Enter key as "hello" :
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `limitCount`, `limitCountNotZero`<a name="placeholders-parameters-limitcount_limitcountnotzero"> </a>
|
#### <a name="placeholders-parameters-limitcount_limitcountnotzero"></a>`limitCount`, `limitCountNotZero`
|
||||||
|
|
||||||
A length of a current value of the [`limit`](#basic_options-limit) option.
|
A length of a current value of the [`limit`](#basic_options-limit) option.
|
||||||
When the value of the [`limit`](#basic_options-limit) option is empty, `'${limitCount}'` is replaced to `'0'`, `'${limitCountNotZero}'` is replaced to `''`.
|
When the value of the [`limit`](#basic_options-limit) option is empty, `'${limitCount}'` is replaced to `'0'`, `'${limitCountNotZero}'` is replaced to `''`.
|
||||||
|
@ -1509,7 +1509,7 @@ action = readlineSync.question(
|
||||||
Choose action from 5 actions :
|
Choose action from 5 actions :
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `lastInput`<a name="placeholders-parameters-lastinput"> </a>
|
#### <a name="placeholders-parameters-lastinput"></a>`lastInput`
|
||||||
|
|
||||||
A last input from the user.
|
A last input from the user.
|
||||||
In any case, this is saved.
|
In any case, this is saved.
|
||||||
|
@ -1528,7 +1528,7 @@ command = readlineSync.prompt({
|
||||||
wrong-command is not available.
|
wrong-command is not available.
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `history_mN`<a name="placeholders-parameters-historymn"> </a>
|
#### <a name="placeholders-parameters-historymn"></a>`history_mN`
|
||||||
|
|
||||||
When the history expansion feature is enabled (see [`history`](#basic_options-history) option), a current command line minus `N`.
|
When the history expansion feature is enabled (see [`history`](#basic_options-history) option), a current command line minus `N`.
|
||||||
*This feature keeps the previous input only.* That is, only `history_m1` is supported.
|
*This feature keeps the previous input only.* That is, only `history_m1` is supported.
|
||||||
|
@ -1550,7 +1550,7 @@ hello
|
||||||
-- You said "hello"
|
-- You said "hello"
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `cwd`, `CWD`, `cwdHome`<a name="placeholders-parameters-cwd_cwd_cwdhome"> </a>
|
#### <a name="placeholders-parameters-cwd_cwd_cwdhome"></a>`cwd`, `CWD`, `cwdHome`
|
||||||
|
|
||||||
A current working directory.
|
A current working directory.
|
||||||
|
|
||||||
|
@ -1568,7 +1568,7 @@ command = readlineSync.prompt({prompt: '[${cwdHome}]$ '});
|
||||||
[~/foo/bar]$
|
[~/foo/bar]$
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `date`, `time`, `localeDate`, `localeTime`<a name="placeholders-parameters-date_time_localedate_localetime"> </a>
|
#### <a name="placeholders-parameters-date_time_localedate_localetime"></a>`date`, `time`, `localeDate`, `localeTime`
|
||||||
|
|
||||||
A string as current date or time.
|
A string as current date or time.
|
||||||
|
|
||||||
|
@ -1587,7 +1587,7 @@ command = readlineSync.prompt({prompt: '[${localeDate}]> '});
|
||||||
[04/21/2015]>
|
[04/21/2015]>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `C1-C2`<a name="placeholders-parameters-c1_c2"> </a>
|
#### <a name="placeholders-parameters-c1_c2"></a>`C1-C2`
|
||||||
|
|
||||||
_For [`limit` option for `keyIn*` method](#basic_options-limit-for_keyin_method) and [`charlist`](#utility_methods-questionnewpassword-options-charlist) option for [`questionNewPassword`](#utility_methods-questionnewpassword) method only_
|
_For [`limit` option for `keyIn*` method](#basic_options-limit-for_keyin_method) and [`charlist`](#utility_methods-questionnewpassword-options-charlist) option for [`questionNewPassword`](#utility_methods-questionnewpassword) method only_
|
||||||
|
|
||||||
|
@ -1602,7 +1602,7 @@ password = readlineSync.questionNewPassword('PASSWORD :', {charlist: '${a-z}'});
|
||||||
|
|
||||||
See also [`limit` option for `keyIn*` method](#basic_options-limit-for_keyin_method).
|
See also [`limit` option for `keyIn*` method](#basic_options-limit-for_keyin_method).
|
||||||
|
|
||||||
## With Task Runner<a name="with_task_runner"> </a>
|
## <a name="with_task_runner"></a>With Task Runner
|
||||||
|
|
||||||
The easy way to control a flow of the task runner by the input from the user:
|
The easy way to control a flow of the task runner by the input from the user:
|
||||||
|
|
||||||
|
@ -1649,9 +1649,9 @@ grunt.initConfig({
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
## Note<a name="note"> </a>
|
## <a name="note"></a>Note
|
||||||
|
|
||||||
### Platforms<a name="note-platforms"> </a>
|
### <a name="note-platforms"></a>Platforms
|
||||||
|
|
||||||
The TTY interfaces are different by the platforms. If the platform doesn't support the interactively reading from TTY, an error is thrown.
|
The TTY interfaces are different by the platforms. If the platform doesn't support the interactively reading from TTY, an error is thrown.
|
||||||
|
|
||||||
|
@ -1664,7 +1664,7 @@ try {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Reading by External Program<a name="note-reading_by_external_program"> </a>
|
### <a name="note-reading_by_external_program"></a>Reading by External Program
|
||||||
|
|
||||||
readlineSync tries to read from a console by using the external program if it is needed (e.g. when the input stream is redirected on Windows XP). And if the running Node doesn't support the [Synchronous Process Execution](http://nodejs.org/api/child_process.html#child_process_synchronous_process_creation) (i.e. Node v0.10-), readlineSync uses "piping via files" for the synchronous execution.
|
readlineSync tries to read from a console by using the external program if it is needed (e.g. when the input stream is redirected on Windows XP). And if the running Node doesn't support the [Synchronous Process Execution](http://nodejs.org/api/child_process.html#child_process_synchronous_process_creation) (i.e. Node v0.10-), readlineSync uses "piping via files" for the synchronous execution.
|
||||||
As everyone knows, "piping via files" is no good. It blocks the event loop and a process. It might make the your script be slow.
|
As everyone knows, "piping via files" is no good. It blocks the event loop and a process. It might make the your script be slow.
|
||||||
|
@ -1674,6 +1674,6 @@ Why did I choose it? :
|
||||||
* The good modules (native addon) for the synchronous execution exist, but node-gyp can't compile those in some platforms or Node versions.
|
* The good modules (native addon) for the synchronous execution exist, but node-gyp can't compile those in some platforms or Node versions.
|
||||||
* I think that the security is important more than the speed. Some modules have problem about security. Those don't protect the data. I think that the speed is not needed usually, because readlineSync is used while the user types keys.
|
* I think that the security is important more than the speed. Some modules have problem about security. Those don't protect the data. I think that the speed is not needed usually, because readlineSync is used while the user types keys.
|
||||||
|
|
||||||
## Deprecated Methods and Options<a name="deprecated_methods_and_options"> </a>
|
## <a name="deprecated_methods_and_options"></a>Deprecated Methods and Options
|
||||||
|
|
||||||
See [README-Deprecated.md](README-Deprecated.md).
|
See [README-Deprecated.md](README-Deprecated.md).
|
||||||
|
|
Loading…
Reference in a new issue