Interactive generator


#1

Hi,
I am currently writing a rails generator. However it will be a little
bit more complex than the standard generators (e.g. model). Therefore I
do not want, that the user has to give all arguments as parameters to
the generator script.
I thought about an interactive generator, that asks the user to enter
different parameters and reads them with “gets”.
When I have a “gets” in the manifest method of my generator, it raises
an error "no such file or directory - <args[0]>
Does anyone have an idea how I can read user input in a generator
script?


#2

Hi all,
I could solve the problem myself. For whomever it might be useful, the
problem was that “gets” tried to read a file named after the first input
parameter to the generator script. Therefore $stdin.gets must be used.

Cheers
Bernd

Bernd B. wrote:

Hi,
I am currently writing a rails generator. However it will be a little
bit more complex than the standard generators (e.g. model). Therefore I
do not want, that the user has to give all arguments as parameters to
the generator script.
I thought about an interactive generator, that asks the user to enter
different parameters and reads them with “gets”.
When I have a “gets” in the manifest method of my generator, it raises
an error "no such file or directory - <args[0]>
Does anyone have an idea how I can read user input in a generator
script?