Edward Yu
Edward Yu

Reputation: 786

commander.js - .prompt removed, now what?

In commander.js, when asking for user input, I would use the prompt method:

program.prompt('name: ', function(name){
  console.log('hi %s', name);
});

But now that method has been removed in version 2.0.0. What is the new method to ask for user input?

Upvotes: 11

Views: 7226

Answers (3)

Polor Beer
Polor Beer

Reputation: 2012

Also checkout inquirer. It is inspired by commander, but has much more functionalities and a beautiful UI.

Upvotes: 6

Vahe Hovhannisyan
Vahe Hovhannisyan

Reputation: 480

Check the prompt removing commit description on github. Now you can use this.

Upvotes: 2

Peter Lyons
Peter Lyons

Reputation: 146064

Update: looks like promptly is the new home for these functions.

This change is being discussed in this github issue. My guess is TJ thinks that functionality belongs in a separate module. Not sure if he plans to migrate the code to a new module or going to leave that to the community, though. But in the end probably one of these outcomes will occur:

  • TJ (or someone else, possibly you) will publish a new library containing this functionality
  • You can just grab the relevant code and make a library or stuff it into your project until a public module is available

Upvotes: 7

Related Questions