DEV Community

Jezer Mejía
Jezer Mejía

Posted on

I made a Node.JS CLI that splits and shows a text on console, just that~

When I was making a simple Node.JS console game, I thought I would need something that prints your text in the console without looking awkward when it surpass the console width, and without the need to use the mouse wheel to move up and down in the text.
I found Inquirer.js, an amazing package that allows pretty and useful command line applications. And, despite Inquirer doesn’t have the feature I wanted (though you could use the editor type; but looks weird to me), I got inspired by its Paginator util used in its list type prompts, so I decided to make something similar to it.
I made the Cl-Paginator package. It splits the text to fit in the terminal and then prints it, allowing the user to move around the text, a-waiting for the user interaction to continue the code.
Here’s an example:

import { Paginator } from cl-paginator

var pag = new Paginator()
await pag.print(Hello world /* or a bigger text */, /* and some options */)

// This won’t continue until the user presses the “return” key

console.log(Finished!)
Enter fullscreen mode Exit fullscreen mode

exampleVid

Wanna try it?

See Cl-Paginator on npm, and Github

npm install cl-paginator
Enter fullscreen mode Exit fullscreen mode

It's my first time writing a post here! Also my first time creating an NPM package~

Top comments (0)