GithubHelp home page GithubHelp logo

Comments (3)

LitoMore avatar LitoMore commented on June 2, 2024 2

If a non 'Yes' or 'no' answer is selected, the program should either throw an error that has to be handled, or it could just ask the question again (specifying that the initial input was wrong).

Good point. I seem to have seen similar interactions before.

from inquirer.js.

LitoMore avatar LitoMore commented on June 2, 2024 1

The code is here:

Object.assign(this.opt, {
filter(input) {
let value = rawDefault;
if (input != null && input !== '') {
value = /^y(es)?/i.test(input);
}
return value;
},
});

@rrohans Could you give more background about your scenario and your expected behavior?

@SBoudrias Maybe we can change the logic below will be better:

Object.assign(this.opt, {
  filter(input) {
    if (input != null && input !== '') {
      if (/^y(es)?/i.test(input)) return true;
      if (/^n(o)?/i.test(input)) return false;
    }

    return rawDefault;
  },
});

Or change it to:

if (/^(y|yes)$/i.test(input)) return true;
if (/^(n|no)$/i.test(input)) return false;

from inquirer.js.

rrohans avatar rrohans commented on June 2, 2024

Yeah sure. I was scaffolding a new T3 app using their create t3-app cli tool when I noticed a bug in the way they accept confirm-style inputs. I created an issue with their cli tool and was told that they use Inquirer as part of their cli tool. Upon further inspection, I found that the bug is not with their cli but with inquirer itself, as you pointed out in the code above. Ideally, if a non 'Yes' or 'no' answer is selected, the program should either throw an error that has to be handled, or it could just ask the question again (specifying that the initial input was wrong).

from inquirer.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.