zx icon indicating copy to clipboard operation
zx copied to clipboard

Feature request: wrap enquirer for questions

Open JannieT opened this issue 3 years ago • 4 comments

Currently the question() function is awkward to use when you need a user prompt other than basic text input. Will it be a lot of work to wrap enquirer instead? This will bring a lot of elegance and power to the UI, allowing for example, select and multi-select prompts.

JannieT avatar Nov 15 '22 11:11 JannieT

Maybe I'm missing something here but why don't you import it yourself? That's what I do in my scripts (with inquirer instead of enquirer though). You can even replace question() if you really want to.

import { prompt } from 'enquirer'
global.question = prompt

const response = await question({
  type: 'input',
  name: 'username',
  message: 'What is your username?'
});
 
echo(response);

pizzafroide avatar Dec 08 '22 08:12 pizzafroide

@pizzafroide that is actually what we currently do as well, but we have uncompiled hosted scripts that we want to share with a recipe like:

if you have zx installed you can scaffold a new project with:

zx --install https://raw.githubusercontent.com/path/to/script/init.mjs

Trying to avoid a recipe like:

if you have zx and enquirer and chalk and fs installed you can scaffold a new project with ...

JannieT avatar Dec 08 '22 13:12 JannieT

still relevant? Pull request welcome?

rougsig avatar Nov 26 '23 19:11 rougsig

If there is solid indication that the maintainers are interested in this direction, then I would be keen to have a go at a PR. For now, we have settled on dax and have not bumped into any limitations for our use case.

JannieT avatar Nov 27 '23 06:11 JannieT