Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pvorb/node-yamlprompt
Prompt for user input in yaml format
https://github.com/pvorb/node-yamlprompt
Last synced: about 1 month ago
JSON representation
Prompt for user input in yaml format
- Host: GitHub
- URL: https://github.com/pvorb/node-yamlprompt
- Owner: pvorb
- License: mit
- Created: 2012-01-17T13:24:45.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2012-01-17T17:54:56.000Z (almost 13 years ago)
- Last Synced: 2024-04-24T02:40:00.182Z (7 months ago)
- Language: JavaScript
- Homepage: search.npmjs.org/#/yamlprompt
- Size: 145 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.mkd
- License: LICENSE.mkd
Awesome Lists containing this project
README
# yamlprompt
A prompt that asks for yaml input.
## Installation
`npm install yamlprompt` or `npm install -g yamlprompt`
## Usage
`test.js`:
```js
var yamlprompt = require('yamlprompt');
// Create readline interface
var rl = require('readline').createInterface(process.stdin, process.stdout);
rl.setPrompt('> ', 2);yamlprompt(rl, function (err, obj) {
if (err)
throw err;// print the parsed yaml document
console.log(obj);
});
```This will give you a prompt, where you can type in yaml and it will print the
corresponding JS object. Stop parsing input by typing `...`.```
$ node test.js
> key: value,
> array: [ some, values, in, an, array ]
> array2:
> - 1
> - 2
> indentation: |
> indented
> ...
{ key: 'value',
array: [ 'some', 'values', 'in', 'an', 'array' ],
array2: [ 1, 2 ],
indentation: 'indented' }
```There is also a binary that can be used from the command line. It converts the
YAML input to JSON.```
$ yamlprompt
> key: value
> ...
{
"key": "value"
}
```You can redirect it's output to a file.
```
$ yamlprompt > output.json
> key: value
> ...
```You can also pass one file to the prompt to let it act like a conversion tool.
```
$ yamlprompt test.yml > output.json
```## Bugs and Issues
If you encounter any bugs or issues, feel free to open an issue at
[github](//github.com/pvorb/node-yamlprompt/issues).## License
The [MIT license](http://vorb.de/license/mit.html).