Re: Idea for an OOP frontend for Console/Getopt.php

From: Date: Mon, 02 Feb 2004 04:11:23 +0000
Subject: Re: Idea for an OOP frontend for Console/Getopt.php
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-25412@lists.php.net to get a copy of this message
Hi Christian, Christian Hammers wrote:
Hello On Thu, Jan 29, 2004 at 12:35:00PM -0500, Greg Beaver wrote:
I could see a new method in Console_Getopt that would take 3 arguments, the long, short options and an object. Also, any command-line that is passed more than once could simply be added to an array if (isset($obj->key)) { if (!is_array($obj->key)) {
       $obj->key = array($obj->key);
} $obj->key[] = $value; } However, I see no reason for using an object as an array - this would just slow things down. After all, what's the difference between $obj['key'] and $obj->key? 2 characters? You still have to do isset()
Sadly it's not that simple. Currently you get back something like this: Right, but I was talking about your code, not the existing Console_Getopt
Well apart from that my main concern is just that the current class makes it much to complicated for simple programs to get their args. Other suggestions are: [snip] 2. If, for compatibility the above mentioned array struction should be kept, then some additional funktions would improve the class: I don't think keeping compatibility is in keeping with your idea - compatibility can be maintained by not modifying existing functionality, and simply adding new in.
An interesting possibility that occurs to me would be to design drivers for the Config class that would read input from the Console, or from the web. This would also allow easy reading from custom configuration files, and fit into more of the goals you describe. Greg

« previous php.pear.dev (#25412) next »