DEV Community

Jezer Mejía
Jezer Mejía

Posted on

3 1

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~

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay