Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.3.5

Request #2445 Don't limit to $_SERVER['argv']
Submitted: 2004-10-04 12:48 UTC Modified: 2004-10-13 07:48 UTC
From: pearbugs at unspeakable dot net Assigned: scottmattocks
Status: Closed Package: Console_Getargs
PHP Version: 4.3.9 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2004-10-04 12:48 UTC] pearbugs at unspeakable dot net
Description: ------------ I'd love to use Getargs in the same way I can use Getopt, which is to say that I don't use it for $_SERVER['argv'] but rather to parse strings within a larger application. Is there any way you could take a string argument in addition to the config argument?

Comments

 [2004-10-04 12:52 UTC] pearbugs at unspeakable dot net
er s/string/array/
 [2004-10-05 02:58 UTC] bmansion at mamasam dot com
I don't understand what you mean neither what you want to do. If Getopt does the job, why not use this package ?
 [2004-10-05 07:12 UTC] pearbugs at unspeakable dot net
Sorry, I had a feeling I was being unclear. I don't want to continue using Getopt because it seems less flexible and has an annoying bug (that I've yet to report.) I'm basically asking to be able to pass in the 'args' to Getargs instead of it being solely for $_SERVER['args']. I've got a function that will take a string and split it up like a shell would (quoted strings and words and whatnot,) returning an array. I can pass user input into it and use the array that it returns as an argument to Console::Getopt. It would be great if I could do the same thing with the seemingly more flexible Getargs. You could even write it so that if the user doesn't pass the arguments in, that it acts on $_SERVER['args'] as a default, and I'm sure you know that. Sorry if this, too, is unclear!
 [2004-10-05 07:21 UTC] bmansion at mamasam dot com
This can be interesting. Now if you could provide a patch against the latest cvs version and a test file... :) ...Unless Scott got some time to deal with this request but I am not sure he is awake yet where he lives, so I suggest we wait a bit. I don't have the time myself to take care of this at the moment.
 [2004-10-05 07:24 UTC] christian at wenz dot org
since I am on the road for the next two weeks, I too would prefer a diff ATM ;-)
 [2004-10-05 07:28 UTC] scott at crisscott dot com
I'm going to try and tackle requests as they come in. I should be able to resolve the previous one later today and then I will get to this. It doesn't sound like it would be too much trouble to implement and I don't see any BC breaks that would arise. By Thursday I should be able to get this into CVS.
 [2004-10-07 05:02 UTC] toggg
The way Getargs is made means a minimal patching (or not) for what you like to do. Anyway parameters differ, but should be no big pb to transform in this direction ( from ...opt to ...args) Easy to add a function to redirect the $this->args to a lot of stuff you prefer. I dont believe it's so unreachable. bye bertrand Gugger
 [2004-10-13 07:48 UTC] scottmattocks
An optional array can now be passed to be used instead of $_SERVER['argv']. The following lines are commented out in the example script. Uncommenting them will show the new functionality. $test = array('-dvw', 500, 'foo1', 'foo2'); $args =& Console_Getargs::factory($config, $test); Scott