vendredi 24 mars 2017

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

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: http://ift.tt/2nl0HH2 .

Aucun commentaire:

Enregistrer un commentaire