How to pass commandline arguments to a file loaded with "irb -r file"?

Hi, I run "irb -r myfile.rb" and would like "myfile.rb" to receive commandline
arguments, and these not to conflict with irb parameters.

Is it possible? I couldn't get it. What I'd like is something as:

~# irb -r myfile.rb -p 9898 -s lala

so ARGVinspected in "myfile.rb" would contain:
["-p", "9898", "-s", "lala"]

Is it possible? Thanks a lot.

···

--
Iñaki Baz Castillo <ibc@aliax.net>

#require is not build to pass arguments around - neither is #load.
One of the reasons is that you do not know whether the file is
actually loaded at that moment.

The easier solution is probably to do it the other way round: build a
script which processes arguments and then fires off IRB. You can look
at your "irb" script to get a starting point how to do that. The you
would do

myfile.rb -p 9898 -s lala

and receive an IRB prompt.

Kind regards

robert

···

2009/12/23 Iñaki Baz Castillo <ibc@aliax.net>:

Hi, I run "irb -r myfile.rb" and would like "myfile.rb" to receive commandline
arguments, and these not to conflict with irb parameters.

Is it possible? I couldn't get it. What I'd like is something as:

~# irb -r myfile.rb -p 9898 -s lala

so ARGVinspected in "myfile.rb" would contain:
["-p", "9898", "-s", "lala"]

Is it possible? Thanks a lot.

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

It makes lot of sense. Thanks a lot.

···

El Miércoles, 23 de Diciembre de 2009, Robert Klemme escribió:

2009/12/23 Iñaki Baz Castillo <ibc@aliax.net>:
> Hi, I run "irb -r myfile.rb" and would like "myfile.rb" to receive
> commandline arguments, and these not to conflict with irb parameters.
>
> Is it possible? I couldn't get it. What I'd like is something as:
>
> ~# irb -r myfile.rb -p 9898 -s lala
>
> so ARGVinspected in "myfile.rb" would contain:
> ["-p", "9898", "-s", "lala"]
>
> Is it possible? Thanks a lot.

#require is not build to pass arguments around - neither is #load.
One of the reasons is that you do not know whether the file is
actually loaded at that moment.

The easier solution is probably to do it the other way round: build a
script which processes arguments and then fires off IRB. You can look
at your "irb" script to get a starting point how to do that. The you
would do

myfile.rb -p 9898 -s lala

and receive an IRB prompt.

--
Iñaki Baz Castillo <ibc@aliax.net>