Feature #8862

getoptlong to accept user-provided commandline

Added by Fabrice Bauzac 8 months ago.

[ruby-core:57013]
Status:Open
Priority:Normal
Assignee:-
Category:lib
Target version:-

Description

=begin
Hello,

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 (({ARGV})).

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)})) method to set (({@argv})) to a copy of the argument.
=end

Also available in: Atom PDF