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

Request #16370 Allow pre-processing of arguments for lists.
Submitted: 2009-06-23 19:42 UTC
From: rquadling Assigned: izi
Status: Closed Package: Console_CommandLine (version 1.1.0)
PHP Version: 5_3 CVS-2009-06-23 OS: Windows XP SP3
Roadmaps: (Not assigned)    
Subscription  


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 10 + 36 = ?

 
 [2009-06-23 19:42 UTC] rquadling (Richard Quadling)
Description: ------------ Hi. Currently, if using 'choices', the case of the value being tested is important. public function dispatchAction($value, $result, $parser) { // check value is in option choices if (!empty($this->choices) && !in_array($value, $this- >choices)) { And whilst this may be the norm for non windows users, on windows, many times data is held cased but is accessed case- less (SQL Server, Windows file names, etc.) My feature request would be to allow a new method for Console_CommandLine_Action which may be overwritten by subclasses actions. This method is a pre-formatter or tidy-up-er for values being submitted. So. I have a new action. class Console_CommandLine_Action_StoreArrayUnique extends Console_CommandLine_Action_StoreArray The execute() method for this is ... public function execute($value = false, $params = array()) { parent::execute($value, $params); $this->setResult(array_unique($this->getResult())); } So far so good. Now I want a unique caseless array. class Console_CommandLine_Action_StoreArrayUniqueCaseless extends Console_CommandLine_Action_StoreArrayUnique For the sake of simplicity, I would upper case them ... public function execute($value = false, $params = array()) { parent::execute(strtoupper($value), $params); } But the execute() method is called to late. The value is already rejected. So. My idea is to amend the Console_CommandLine_Option::dispatchAction() method so that the Action class is loaded first and then a new method ( format() ) can be called. Patches supplied.

Comments

 [2009-06-23 19:43 UTC] rquadling (Richard Quadling)
The following patch has been added/updated: Patch Name: allow-formatting-of-choice Revision: 1245768183 URL: http://pear.php.net/bugs/patch-display.php?bug=16370&patch=allow-formatting-of-choice&revision=1245768183&display=1
 [2009-08-18 16:32 UTC] izi (David Jean Louis)
Hi Richard, I'm +1 on adding the format() method, very good idea, it can be useful for other actions as well. But I'm -1 on adding the StoreArrayUnique and StoreArrayUniqueCaseless actions, they're very specific and can live outside the package without problem with the registerAction() facility. What do you think ? Could you update the patch ? Thanks, -- David
 [2009-08-18 17:41 UTC] rquadling (Richard Quadling)
Yep. Will do. I must admit, the fact that I can register them when I need them is fine. I wonder though. Rather than registering all the actions up front, how about registering them when used? That way you could have 2 pools of actions - predefined and user defined pools. Then as an action is required, register it from the pools and error if not known. Less is loaded upfront. Less memory used and only a small during the adding of options (maybe - only just thought of this). I'll fix this patch first though.
 [2009-08-18 18:11 UTC] rquadling (Richard Quadling)
The following patch has been added/updated: Patch Name: allow-formatting-of-choice Revision: 1250601104 URL: http://pear.php.net/bugs/patch-display.php?bug=16370&patch=allow-formatting-of-choice&revision=1250601104&display=1
 [2009-08-18 18:20 UTC] rquadling (Richard Quadling)
The following patch has been added/updated: Patch Name: allow-formatting-of-choice Revision: 1250601610 URL: http://pear.php.net/bugs/patch-display.php?bug=16370&patch=allow-formatting-of-choice&revision=1250601610&display=1
 [2009-11-11 22:55 UTC] izi (David Jean Louis)
-Status: Open +Status: Closed -Assigned To: +Assigned To: izi
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Patch applied, thanks Richard.