This patch renders other patches obsolete
Obsolete patches:
Index: trunk/Console/CommandLine/Action.php
===================================================================
--- trunk/Console/CommandLine/Action.php (revision 287440)
+++ trunk/Console/CommandLine/Action.php (working copy)
@@ -95,9 +95,24 @@
}
// }}}
- // setResult() {{{
+ // format() {{{
/**
+ * Allow a value to be pre-formatted prior to being used in a choices test.
+ * Setting $value to the new format will keep the formatting.
+ *
+ * @param mixed &$value The value to format
+ *
+ * @return mixed The formatted value
+ */
+ public function format(&$value)
+ {
+ return $value;
+ }
+
+ // }}} // setResult() {{{
+
+ /**
* Convenience method to assign the result->options[name] value.
*
* @param mixed $result The result value
Index: trunk/Console/CommandLine/Option.php
===================================================================
--- trunk/Console/CommandLine/Option.php (revision 287440)
+++ trunk/Console/CommandLine/Option.php (working copy)
@@ -240,8 +240,19 @@
*/
public function dispatchAction($value, $result, $parser)
{
+ $actionInfo = Console_CommandLine::$actions[$this->action];
+ if (true === $actionInfo[1]) {
+ // we have a "builtin" action
+ $tokens = explode('_', $actionInfo[0]);
+ include_once implode('/', $tokens) . '.php';
+ }
+ $clsname = $actionInfo[0];
+ if ($this->_action_instance === null) {
+ $this->_action_instance = new $clsname($result, $this, $parser);
+ }
+
// check value is in option choices
- if (!empty($this->choices) && !in_array($value, $this->choices)) {
+ if (!empty($this->choices) && !in_array($this->_action_instance->format($value), $this->choices)) {
throw Console_CommandLine_Exception::factory(
'OPTION_VALUE_NOT_VALID',
array(
@@ -253,16 +264,6 @@
$this->messages
);
}
- $actionInfo = Console_CommandLine::$actions[$this->action];
- if (true === $actionInfo[1]) {
- // we have a "builtin" action
- $tokens = explode('_', $actionInfo[0]);
- include_once implode('/', $tokens) . '.php';
- }
- $clsname = $actionInfo[0];
- if ($this->_action_instance === null) {
- $this->_action_instance = new $clsname($result, $this, $parser);
- }
$this->_action_instance->execute($value, $this->action_params);
}