Closed themightychris closed 6 years ago
Hi @themightychris! There isn't at the moment, but it's not hard to implement. See here, we are filtering options with prompt
set to false
. We can add another value to only filter these options if the value is set.
Is that what you are looking for?
@nanovazquez that sounds about right!
Alright, I think we should change the prompt property to receive 3 values: always
, never
and if-empty
. By default it will be set to if-empty
, prompting if the value was not provided either via the command line or the default values.
I've started this branch to release the new version of the library, that will include this (breaking) change. Feel free to continue the implementation, otherwise, I'll add the code during the week.
If boolean values could be interpreted with something like typeof prompt == 'boolean' ? (prompt ? 'always' : 'never') : prompt
then it wouldn't need to be a breaking change, right?
You are right. But should we? As long as we release a new version I don't see the problem of treating it as a breaking change (unless I'm missing something).
We have a candidate in #9. I'll work on the tests and release it as soon as they pass.
There you go, @themightychris. The new prompt
option, with the if-empty
configuration is now available in v2.0.0. You can use it by simply doing something like this:
const options = {
name: {
prompt: 'if-empty';
}
...
};
And then yargs-interactive will prompt the name
option if a value was not supplied via default value or command parameters.
amazing work, thank you @nanovazquez !
Is there a usage where prompts can be shown only for options not set via command line?