Open derekprior opened 10 years ago
I invoke it with run_generator["foo", "--sql bar"] but inside the generator options[:bar] is nil
Shouldn't that be options[:sql]
?
Yes. That was a typo in the issue. Still seems to be a problem.
On Wednesday, August 13, 2014, Michał Matyas notifications@github.com wrote:
I invoke it with run_generator["foo", "--sql bar"] but inside the generator options[:bar] is nil
Shouldn't that be options[:sql] ?
— Reply to this email directly or view it on GitHub https://github.com/alexrothenberg/ammeter/issues/41#issuecomment-52022701 .
I believe it works if you separate the name and value like
run_generator["foo", "--sql", "bar"]
I have a generator that inherits from NamedBase and defines a
--sql
class_option
.I invoke it with
run_generator["foo", "--sql bar"]
but inside the generatoroptions[:bar]
isnil
. I looked at the implementation ofrun_generator
andgenerator
and saw that it's using Thor to parse the options. I verified thatThor::Options.splt
works as expected on the array I'm passing torun_generator
... and yet, still the option in nil in the generatornd it seems that indeedargs
andopts
are getting set correctly. And yet, the option is still nil in my tests.Compounding the problem (and limiting my normal debug tools) is that it seems
pry
does not work inside the generator. It works in my non-generator spec and even works when I run the generator from the command line, outside of my tests. But in my generator specs, pry opens but no statements return anything. I can call methods, non-existent methods, pry method -- none of them do anything.The generator runs as expected when I try it from the command line so the problem is indeed limited to the specs.