This project is archived and is in readonly mode.
Interactive Rails template
-
rubymood
Making Rails template interactive, so user can interaction whit the running command.
Example for compass gem:
if yes?("Do you wanna manually config compass?") run "compass --rails -f #{ask("Wich framework want to use?")} .", :interactive=>true else run "compass --rails -f blueprint .", :puts=>["y","n"] end:puts sends arguments to stdin, so it could be use for automatic configuration. -
rubymood
Making Rails template interactive, so user can interaction whit the running command.
Example for compass gem:
if yes?("Do you wanna manually config compass?") run "compass --rails -f #{ask("Wich framework want to use?")} .", :interactive=>true else run "compass --rails -f blueprint .", :puts=>["y","n"] end:puts sends arguments to stdin, so it could be use for automatic configuration.
-
CancelProfileIsBroken
- Assigned user set to Pratik
- Tag changed from template_runner to patch, template_runner
-
Pratik
- State changed from new to wontfix
I think this is making the API more complex than needed. If more people ask for this, I'd be happy to commit. What's the alternative you are using at the moment ?
Thanks.
-
rubymood
I'm using the approaches in the patch in my template file when is needed. But I think it's a good option to run commands only with the run method and passing params to it how to run. (so I'm think the run_ruby_script isnt needed, because when running ruby command in windows you should simply put ruby before the command, but FYI this method is not removed from my patch)
-
rubymood
Or we should maybe merge run_ruby_script with run method.
-
rubymood
Some more explanation and patch update.
When somebody - with the current Rails version - want to generating new Rails app with template file and in this process want to config/install something that needing some interaction, the rails app generating will stop, waiting the input and don't show anything.
new patch: * run_ruby_script merged into run * well documented
-
rubymood
sorry, my last patch works on windows just for ruby scripts.. and for now I've changed more things:
Now for ruby script:
run "ruby_script.rb", :ruby_script => trueTo check command response or when interaction is needed:
run "compass --rails -f blueprint .", :show_reponse=>trueFor automatized tasks:
run "compass --rails -f blueprint .", :puts=>["y","n"] -
Jeremy McAnally
In my opinion, we're getting outside of the original intent of the feature here. If you need some sort of interactive input beyond yes/no or some basic text input, then it should be a separate script or something that's run post-generation. At that point it's not a template, it's a Turing-complete application.
I'm just thinking about the 80% (or probably more likely 95%) case here. It seems like this could live as a gem if people needed it or something, since it's a rather small-scale use case.
-
rubymood
Jeremy, thanks for your response.
The time will answer the question, that the community is needing or not this kind of support for generating application.
Anyway, I upload a working script, to whom it may concern.
