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

question not working with choices #76

Closed
tmus opened this issue May 14, 2021 · 3 comments
Closed

question not working with choices #76

tmus opened this issue May 14, 2021 · 3 comments

Comments

@tmus
Copy link

tmus commented May 14, 2021

Expected Behavior

The choices are displayed when asking a question that contains choices.

Actual Behavior

No choices are displayed: the user can enter any value.

Steps to Reproduce the Problem

#!/usr/bin/env zx

const number = await question("Pick a number: ", {
  choices: ["1", "2"],
});
  1. Run the above.
  2. See that no choices are displayed.

image

Specifications

  • Version: 1.6.0
  • Platform: macOS 10.14.6
@DavidIsa DavidIsa mentioned this issue May 14, 2021
2 tasks
@antonmedv
Copy link
Collaborator

It uses readline autocomplete. Press Tab twice.

@waketzheng
Copy link

This worked for me:

#!/usr/bin/env zx

const prompts = require('prompts') // npm install prompts
const questions = [
  {
    type: 'text',
    name: 'dish',
    message: 'Would you like some cocktail? ',
  },
  {
    type: 'select',
    name: 'version',
    message: 'Which part do you want to bump? ',
    choices: [
      { title: 'patch: ' + nextPatch, value: nextPatch },
      { title: 'minor: ' + nextMinor, value: nextMinor },
      { title: 'major: ' + nextMajor, value: nextMajor },
    ],
  },
]

const response = await prompts(questions)
const newVersion = response.version
if (newVersion) {
  console.log(newVersion)
}

@lixioo
Copy link

lixioo commented Mar 27, 2023

does it work? the choices still not working,how can i question with options?

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

Successfully merging a pull request may close this issue.

4 participants