Forum: Ruby-core [ruby-trunk - Feature #8862][Open] getoptlong to accept user-provided commandline

F993d626561695d08afc31dc3efab6d7?d=identicon&s=25 noon (Fabrice Bauzac) (Guest)
on 2013-09-04 14:53
(Received via mailing list)
Issue #8862 has been reported by noon (Fabrice Bauzac).

Feature #8862: getoptlong to accept user-provided commandline

Author: noon (Fabrice Bauzac)
Status: Open
Priority: Normal
Category: lib
Target version:


The (({getoptlong})) module (({class GetoptLong})) provides no way for
the user to provide a commandline that is not (({ARGV})).  It appears
that (({GetoptLong})) is tied to the (({ARGV})) global variable and this
cannot be modified.  The fine (({getoptlong})) algorithms are not
reusable in particular situations where the command is not in
(({ARGV})), short of performing some kind of hack to temporarily modify

This ticket requests the addition of a way to redirect a
(({GetoptLong})) object to eat a different (({Array})) of (({String}))
than (({ARGV})).

One way to implement this would be to change the getoptlong code to use
(({@argv})) instead of (({ARGV})), set (({@argv})) to a copy of
(({ARGV})) in (({#initialize})), and provide a
(({#set_commandline(Array<String>)})) method to set (({@argv})) to a
copy of the argument.
This topic is locked and can not be replied to.