nanovazquez / yargs-interactive

Interactive support for yargs
MIT License
46 stars 9 forks source link

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

Closed allenchuang closed 2 years ago

allenchuang commented 2 years ago

^ 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 commented 2 years ago

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 commented 2 years ago

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

image
github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version 3.0.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: