On Jun 20, 4:18 pm, "Robert Dober" <robert.do... / gmail.com> wrote:
> On 6/20/07, Trans <transf... / gmail.com> wrote:
>
>
>
> > Is there a way to utilize Getoptlong on an arbitrary command var, ie.
> > not on ARGV. I figure I can alway do something like:
>
> >   require 'getoptlong'
>
> >   my_argv = Shellwords.shellwords( "foo -x" )
>
> >   const_set(:ARGV,  my_argv)
>
> >   opts = GetoptLong.new(
> >     [ '-x', GetoptLong::NO_ARGUMENT ]
> >   )
>
> > But it just doesn't seem proper to reset ARGV.
>
> > Thanks,
> > T.
>
> Basically did
> %s/ARGV/(@arglist||ARGV)/g
> and inserted the attribute accessor, funny thing seems to work ;)
>
> opts = GetoptLong.new(
>    [ '-x', GetoptLong::NO_ARGUMENT ]
>  )
> opts.arglist = Shellwords.shellwords( "foo -x" )

Ah, so we need a patch. Okay well I guess I'll post that up on the
board too.

Thanks Robert,
T.