IndigoUnited / automaton

Task automation tool built in JavaScript
http://indigounited.com/automaton
MIT License
214 stars 10 forks source link

Prompt functions #44

Closed marcooliveira closed 11 years ago

marcooliveira commented 11 years ago

It would be useful to provide the user with prompt functions in the task context, so he can request information to the user, if necessary. We could provide something like ctx.prompt, with a few functions.

Check https://github.com/visionmedia/commander.js/#promptmsg-fn for examples of these functions.

marcooliveira commented 11 years ago

Relates to #45

satazor commented 11 years ago

I like the API of commander and dislike this one: https://github.com/flatiron/prompt

satazor commented 11 years ago

After evaluating, I decided to implement a separate nodejs module for this. We could use commander's one but we would have to depend on a lot of things just for the prompt functions. Besides that, we are using optimist instead of commander.

Check it out: https://github.com/IndigoUnited/node-promptly It has a simple API. Everything is done, except for the password prompt.

satazor commented 11 years ago

Ok everything is done. Under the hood, it uses isaac's read node module.

satazor commented 11 years ago

@marcooliveira I'm going to integrate promptly in automaton. Question: should we preserve the indentation when questioning things to the user or not? If not, context.prompt = promptly, otherwise we must have a proxy to indent the prompt messages.

marcooliveira commented 11 years ago

Very nice! I like the module, simple as it should be ;)

Good question. Having prompts indent like logging does, can eventually put the prompt in an awkward position. Let's take a practical look at this. I think most people will only depend on user input on top tasks. Even if they read values from inner tasks, I don't think it's a must to have them indented. If this proves to be an annoyance, we can always indent later. This also makes automaton more efficient.

satazor commented 11 years ago

Btw I've added this in the context, but since we don't make indentation, it is context independent. As soon as #45 is done, we can move it there or not...