nanovazquez / yargs-interactive

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

How do you use it with commands? #48

Open JoshMcCullough opened 2 years ago

JoshMcCullough commented 2 years ago

I don't see how to use this package with commands. E.g. ...

yargsInteractive()
    .command('do-it', 'Does things.', o => o
      .options(myOptions))
    .strict()
    .demandCommand()
    .help()
    .argv;

I can only call .interactive(...) and pass in options directly from the yargsInteractive() return. I can't seem to configure an interactive command.

yfwz100 commented 2 years ago

I am looking for command support too...

nanovazquez commented 2 years ago

Hey @JoshMcCullough and @yfwz100 . Can you provide the use cases you are looking for with more detail? If you want to use command, why not use yargs directly?

The purpose of the library is to provide support for interactivity commands, using a yargs fashion, but also add the ability to pass values to these commands when the interactivity is not needed (i.e. in CI environments).

JoshMcCullough commented 2 years ago

The use case is myapp do-it with an arg, e.g. name. When name is not provided as an argument on the command line, then we'd like yargs-interactive to prompt for it. Currently you can only do interactive stuff without commands.

walterra commented 1 year ago

I came here looking for the same and thought it was somehow supported since the examples use .usage('$0 <command> [args]') which would hint at "command" support. If that's not the case and not planned maybe these description should be updated to say just .usage('$0 [args]')? Still agree with previous posters that the use case would be to have a main script with several commands where each command would support an interactive mode.