You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is more of an idea for discussion. If any argument to .task after the first argument is a string that ends with ?, register it as a confirmation prompt, and conditionally run any arguments that follow if the prompt returns true.
Example:
composer.task('install','Want to install dependencies?',function(cb){// this will only run if prompt is confirmed by usercb();});// orcomposer.task('prompt-install','Want to install dependencies?',['install','something','else']);// orcomposer.task('install','Want to install dependencies?',function(cb){// run this if "true"cb();},function(){// run this if "false"cb();});
The conventions for how "prompt tasks" work could differ from normal tasks.
Normally I would recommend this be done in a plugin or implementation, but after trying to create a plugin to do it, I'm thinking it would be really easy to do here. (Fwiw, I already have a working plugin that I can publish to npm if we decide to go that route. It just occurred to me that it would be awesome to have here as a built-in feature).
edit: the more I think about it, I think we should consider having Composer inherit from Enquirer, and have built-in support for all of the prompt types, or at least a handful of them. We just need to document how those prompt types work and expected behavior. This would make composer totally different than any other flow control library, and I think assemble, generate, verb and update users would really like this feature. It would also make composer more awesome for general CLI usage.
Ideas:
task and/or build can return the answers in the callback.
we can limit prompt functionality to specific conventions, like having the first and second args be strings
if composer inherits enquirer, we could allow prompts to be composed as tasks. Meaning that when task foo is run by build, composer would look for a prompt named foo and, if found, will run the prompt, otherwise, continue with the deps (how this is handled doesn't matter. composer might splice the prompt into the deps or something, but to the user it would be transparent)
The text was updated successfully, but these errors were encountered:
jonschlinkert
changed the title
feature-request: confirm
feature-request: built-in prompts
Mar 6, 2017
I like the idea of starting off with the confirmation prompt and going from there. I can already see how the code will work for based on the ideas above and the plugin you mentioned.
We could add additional prompts using the same convention (if second argument is a string ending with ?), and allowing the options to be passed into enquirer to specify the prompt type. Then instead of using y/n to determine which task function to run, the task function will just be run and this.answers will be populated with the answers. I think we can also return the answers in the .build callback when used directly.
This is more of an idea for discussion. If any argument to
.task
after the first argument is a string that ends with?
, register it as a confirmation prompt, and conditionally run any arguments that follow if the prompt returnstrue
.Example:
The conventions for how "prompt tasks" work could differ from normal tasks.
Normally I would recommend this be done in a plugin or implementation, but after trying to create a plugin to do it, I'm thinking it would be really easy to do here. (Fwiw, I already have a working plugin that I can publish to npm if we decide to go that route. It just occurred to me that it would be awesome to have here as a built-in feature).
edit: the more I think about it, I think we should consider having Composer inherit from Enquirer, and have built-in support for all of the prompt types, or at least a handful of them. We just need to document how those prompt types work and expected behavior. This would make composer totally different than any other flow control library, and I think assemble, generate, verb and update users would really like this feature. It would also make composer more awesome for general CLI usage.
Ideas:
task
and/orbuild
can return the answers in the callback.foo
is run bybuild
, composer would look for a prompt namedfoo
and, if found, will run the prompt, otherwise, continue with the deps (how this is handled doesn't matter. composer might splice the prompt into the deps or something, but to the user it would be transparent)The text was updated successfully, but these errors were encountered: