Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type: "list" in prompt.js is not working...? #131

Closed
SatoshiKawabata opened this issue Aug 1, 2019 · 4 comments
Closed

type: "list" in prompt.js is not working...? #131

SatoshiKawabata opened this issue Aug 1, 2019 · 4 comments

Comments

@SatoshiKawabata
Copy link

I want to select an item from list by prompt. But type: "list" looks not working... Please help me.

I made prompt.js like this.

module.exports = [
    {
        type: "list",
        choices: ["atoms", "molecules", "organisms", "templates", "pages"],
        name: "direcrory",
        message: `What's atomic directory?`,
    }
};

I execute to create new file. The prompt is below.

What's atomic directory?("atoms", "molecules", "organisms", "templates", "pages") › 

I expected like list.

What's atomic directory?("atoms", "molecules", "organisms", "templates", "pages")
❯◯ atoms
 ◉ molecules
 ◯ organisms
 ◯ templates
 ◯ pages
@ACoolmanBigHealth
Copy link

ACoolmanBigHealth commented Aug 22, 2019

I have the same problem, did you solve it?

Edit: I mixed up enquirer with inquirer

Thus type: "select" works https://github.com/enquirer/enquirer#select-prompt

@Xenithz
Copy link

Xenithz commented Aug 24, 2019

To solve your solution use the "Enquirer" module and destructure the "Select object from it. From there you can create a new list with choices. There is no type called list.

Code example provided below from (https://github.com/enquirer/enquirer#select-prompt).

Issue can probably be closed.

const { Select } = require('enquirer');

const prompt = new Select({
  name: 'color',
  message: 'Pick a flavor',
  choices: ['apple', 'grape', 'watermelon', 'cherry', 'orange']
});

prompt.run()
  .then(answer => console.log('Answer:', answer))
  .catch(console.error);

@jondot
Copy link
Owner

jondot commented Jul 3, 2020

❤️

@jondot jondot closed this as completed Jul 3, 2020
@c1495616js
Copy link

To be specific for above example,

const { Select } = require('enquirer');

const selectPrompt = new Select({
  name: 'color',
  message: 'Pick a flavor',
  choices: ['apple', 'grape', 'watermelon', 'cherry', 'orange']
});
module.exports = {
  prompt: ({ prompter, args }) =>
  selectPrompt.run()
  .then(({ color }) =>
        prompter.prompt({
          type: 'input',
          name: 'folder',
          message: `Please type your color ${color} again:`
        })
      )
      
      
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants