So I'm trying to DRY up a Rake task which runs a script that takes user input, and I've run into the same problem as this poster - by default, just calling gets
assumes that the rake argument (in this case, db:seed
) is a file from which it should read, which of course doesn't exist. I got around this by just calling STDIN.gets
, which works fine, but I'd love to be able to just use gets
the way I can use puts
(Rake seems to have no issue with STDOUT
by default) - as a static method.
Is there any way to force Kernel#gets
to read from STDIN
within Rake? (Or more generally, is there any way to force Kernel#gets
to read from STDIN
when it is ostensibly passed a command line argument?) Or would that be a bad practice?