I know about accessing the command arguments using the ARGV array, but I've run into an issue. I have a script that I cannot run standalone and instead needs to be run in the rails console. Is there a way to pass arguments when calling a file as such?
load '/tmp/test.rb'
I tried placing it inside the quotes, outside and on a whim tried < to no avail.
Thank you for any help you can provide!
It is dirty hack but seems like you can assign array to ARGV and use it from loaded scripts as you wanted in question:
$ Temp cat argv.rb
p ARGV
$ Temp irb
2.1.0 :001 > ARGV
=> []
2.1.0 :002 > load 'argv.rb'
[]
=> true
2.1.0 :003 > ARGV = ['A', 'B']
(irb):3: warning: already initialized constant ARGV
=> ["A", "B"]
2.1.0 :004 > load 'argv.rb'
["A", "B"]
=> true
2.1.0 :005 >
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With