fardjad/node-interactive-commander

Prompt before execution

Narretz opened this issue · 2 comments

Hi, this looks very cool!

However, instead of prompts for the input, I'm looking for a prompt that is shown after options parsing but before actual execution of the script. Obviously I could do this with an option that must be set to true, but I want to do it interactively. Is this even the right library for this?

Thank you!

I might be able to help you better with a small code snippet that demonstrates what you're trying to do.

Also, you might find my other library, parse-my-command useful for the cases interactive-commander cannot support. With that library you can parse the args and implement the logic for showing the prompt manually.

Hi @fardjad thanks for the quick response. I figured out that what I want to do doesn't require your lib. Basically I just want to prompt before doing something like this:

import { confirm } from '@inquirer/prompts';
import { program } from 'commander';

program.command('command<data>').action(async (data, options, command) => {
const result =  await confirm({ message: 'Run the command?' });
if (result) {
  console.log('success', data);
}
});

I didn't think it was that easy ;)