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

Following your example adding --interactive doesn't allow interactive mode #41

Closed
allenchuang opened this issue Feb 5, 2022 · 3 comments
Labels

Comments

@allenchuang
Copy link

^ like what title says.

I'm trying to enter interactive mode, but whatever I do, i can't. Am I missing something here?

i saved the file like so in test.js


const yargsInteractive = require("yargs-interactive");
const options = {
  interactive: { default: true },
  name: { type: "input", default: "A robot", describe: "Enter your name" },
  likesPizza: {
    type: "confirm",
    default: false,
    describe: "Do you like pizza?",
  },
};

yargsInteractive()
  .usage("$0 <command> [args]")
  .interactive(options)
  .then((result) => {
    // Your business logic goes here.
    // Get the arguments from the result
    // e.g. myCli(result.name);
    console.log(
      `\nResult is:\n` +
        `- Name: ${result.name}\n` +
        `- Likes pizza: ${result.likesPizza}\n`
    );
  });

then i run

node test.js --interactive

outputs immediately without prompts:


Result is:
- Name: A robot
- Likes pizza: false

@nanovazquez
Copy link
Owner

Thanks for reporting! There is something weird indeed, I'm not sure if the bug was always there or something changed in the yargs API. Just in case, I've added a patch in the code to make sure Interactive mode is triggered if you explicitly asked for it via arguments.

BTW, we are working on a complete refactor and cleanup, using TypeScript, and a better testing strategy, this is why you don't see any test in the commit that fixes the issue (will be included in the next major). Stay tuned!

@sinkcup
Copy link

sinkcup commented Mar 14, 2022

me too, it seems there is no new tag for this version. @nanovazquez

image

@github-actions
Copy link

🎉 This issue has been resolved in version 3.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

No branches or pull requests

3 participants