mokkabonna / inquirer-autocomplete-prompt

Autocomplete prompt for inquirer
ISC License
354 stars 82 forks source link

Supporting the name, value, short schema #142

Closed ckosmowski closed 2 years ago

ckosmowski commented 2 years ago

Often for lists and choices inquirer supports objects containing name, value and short properties for display, resulting value and displayed short value after selection.

It seems like autocomplete only accepts strings currently. I'd like to request the above as a feature.

mokkabonna commented 2 years ago

This should work, tested it now. What are you doing?

const choicesFull = [
  {
    name: 'Apple',
    value: 'apple-value',
    short: 'apple-short',
  },
];

inquirer
  .prompt([
    {
      type: 'autocomplete',
      name: 'fruit',
      message: 'What is your favorite fruit?',
      searchText: 'We are searching the internet for you!',
      emptyText: 'Nothing found!',
      default: 'Banana',
      source: async () => choicesFull,
      pageSize: 4,
    },
])