Providing an argument that looks like an option (rails runner / OptionParser / optparse)

153 views Asked by At

I have a script magic which uses rails runner to invoke another script magic-foo.rb, which does it's own option parsing. Something like this:

exec("#rails", "runner", "#{some_path}/bin/magic-foo.rb", *arguments)

I want to expose the --help option from magic-foo.rb through magic, but rails runner consumes --help and dies with its own help message.

How can I get an argument that looks like an option through the use of OptionParser in runner.rb? Alternativel, how else can I get magic to evaluate magic-foo.rb in the right rails context with the right arguments?

Because an argument -- is the standard way to say "don't process following arguments" I might expect an invocation like this to work: rails runner .../magic-foo.rb -- [ARGS]. Unfortunately it does not.


Active version of rails runner: https://github.com/rails/rails/blob/880371ef2b4a2cb08f0c36ceba1eee41836bb739/railties/lib/rails/commands/runner.rb .

0

There are 0 answers