Interactive Prompts for Node CLIs

Interactive Prompts for Node CLIs
Average rating: 0
(0 votes)

“Node.js is a tumor on the programming community, in that not only is it completely braindead, but the people who use it go on to infect other people…” We are infected by Node.js too. Today we are going to tell you more about Interactive Prompts for Node CLIs.

Interactive Prompts for Node CLIs are flexible, uses promises throughout, and includes support for validating input. That’s what you need to know about them.

  • Simple: prompts has no big dependencies nor is it broken into a dozen tiny modules that only work well together.
  • User friendly: prompt uses layout and colors to create beautiful cli interfaces.
  • Promised: uses promises and async/await.
  • Flexible: all prompts are independent and can be used on their own.
  • Testable: provides a way to submit answers programmatically.
  • Unified: consistent experience across all prompts.

Prompts Objects are JavaScript objects that define the “questions” and the type of prompt. Almost all prompt objects have the following properties:

{
  type: String | Function,
  name: String | Function,
  message: String | Function,
  initial: String | Function | Async Function
  format: Function | Async Function,
  onRender: Function
  onState: Function
}

Each property is of type function and will be invoked right before prompting the user.

The function signature is (prev, values, prompt), where prev is the value from the previous prompt, values is the response object with all values collected so far and prompt is the previous prompt object.

Check all details on the Prompts GitHub page!

If you interested in how threads in Node.js work, follow the link we mentioned. You are always welcome!

Rate this article, if you like it

Thanks! You’ve rated this material!

Got a project? Let's discuss it!

*By submitting this form you agree with our Privacy Policy.

Mailing & Legal Address

Syndicode Inc. 340 S Lemon Ave #3299, Walnut CA, 91789, USA

Visiting & Headquarters address
Kyiv Sofiivska 1/2a, 01001, Kyiv, Ukraine
Dnipro Hlinky 2, of. 1003, 49000, Dnipro, Ukraine
Email info@syndicode.com
Phone (+1) 9035021111