https://github.com/mongodb-js/pretty-repl
Extends Node's repl.REPLServer to allow for a colorize function.
https://github.com/mongodb-js/pretty-repl
cli node-repl nodejs syntax-highlighting
Last synced: 6 months ago
JSON representation
Extends Node's repl.REPLServer to allow for a colorize function.
- Host: GitHub
- URL: https://github.com/mongodb-js/pretty-repl
- Owner: mongodb-js
- License: mit
- Created: 2020-04-05T16:56:56.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2024-05-14T08:22:53.000Z (almost 2 years ago)
- Last Synced: 2025-06-30T05:03:25.327Z (8 months ago)
- Topics: cli, node-repl, nodejs, syntax-highlighting
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/pretty-repl
- Size: 365 KB
- Stars: 27
- Watchers: 11
- Forks: 4
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pretty REPL

An extension of the Node REPL (`repl.REPLServer`) that applies syntax highlighting as the user types.

## How to use it
Install the package:
```bash
$ npm install --save pretty-repl
```
Use the package:
```javascript
const repl = require('pretty-repl');
const options = {
prompt: '→ '
};
repl.start(options);
```
`options` is an an object with the [same options](https://nodejs.org/api/repl.html#repl_repl_start_options) as `repl.REPLServer`.
Additionally, it's possible to pass an additional `colorize` property to the options object:
```javascript
{
colorize: function (str) {
// str is the the string in input.
// the function should return the string that has been colorized to output in the REPL.
}
}
```
In order to highlighting matching pairs of brackets, a `colorizeMatchingBracket`
is also available.
## Credits
Pretty repl is inspired and includes code fragments from:
* https://github.com/nodejs/repl
* https://github.com/aantthony/node-color-readline