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

Request #16679 Allow arguments to have Actions
Submitted: 2009-10-05 22:27 UTC
From: rquadling Assigned: izi
Status: Wont fix Package: Console_CommandLine (version 1.1.0)
PHP Version: 5_3 CVS-2009-10-05 OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2009-10-05 22:27 UTC] rquadling (Richard Quadling)
Description: ------------ Quite often an argument will be a filename. Being able to specify an action for an argument would be useful so you could verify the supplied argument.

Comments

 [2010-06-06 22:17 UTC] izi (David Jean Louis)
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: izi
I'm not sure this feature request is a good idea, validating arguments doesn't make much sense, closing this as "won't fix".
 [2010-06-07 14:26 UTC] rquadling (Richard Quadling)
The main reason is that a common sequence of events is to ask for a file or directory and then to validate that the file or directory exists. Allowing for this common use pattern would simplify the user's code in that the validation will already be done. The alternative is to create a parameter which requires a file name and a custom action. But then the parameter is no longer mandatory ... Like for PHP... php file.php or php -f file.php the -f is redundant, but would be required for Console_CommandLine to allow for a custom action to verify the existence of file.php
 [2010-06-08 13:35 UTC] izi (David Jean Louis)
>> The main reason is that a common sequence of events is to ask for a file or directory and then to >> validate that the file or directory exists. Yep but I can't see any other common usecase, furthermore sometimes you want to provide a file that does not exists and will be created by the script, like an output file. >> The alternative is to create a parameter which requires a file name and a custom action. But then >> the parameter is no longer mandatory ... Or you could just do: if (!file_exists($parser->args['file'])) { ... } Regards, -- David