From: Chuck Hagenbuch Date: Sat, 30 May 2009 15:02:48 +0000 (-0400) Subject: - Handle "-" in command-line controller names automatically X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=25e8f74b6a562abc46067d0183d7e605b0c39ae3;p=horde.git - Handle "-" in command-line controller names automatically - Allow much more flexibility in setting the path for command line requests --- diff --git a/framework/Controller/lib/Horde/Controller/Request/Cli.php b/framework/Controller/lib/Horde/Controller/Request/Cli.php index a0ec8105c..ea3dd78ee 100644 --- a/framework/Controller/lib/Horde/Controller/Request/Cli.php +++ b/framework/Controller/lib/Horde/Controller/Request/Cli.php @@ -36,15 +36,7 @@ class Horde_Controller_Request_Cli extends Horde_Controller_Request_Base { parent::__construct($options); - $parser = new Horde_Argv_Parser(array( - 'allowUnknownArgs' => true, - 'addHelpOption' => false, - )); - list($this->_argv, $args) = $parser->parseArgs(); - if (!count($args)) { - throw new Horde_Controller_Exception('unknown command: ' . implode(' ', $args)); - } - $this->_path = $args[0]; + $this->setPath(); } public function getUri() @@ -57,6 +49,29 @@ class Horde_Controller_Request_Cli extends Horde_Controller_Request_Base return $this->_path; } + public function setPath($args = null) + { + if (is_string($args)) { + $this->_path = $args; + } else { + if ($args instanceof Horde_Argv_Parser) { + $parser = $args; + } else { + $parser = new Horde_Argv_Parser(array( + 'allowUnknownArgs' => true, + 'addHelpOption' => false, + )); + } + + list($this->_argv, $args) = $parser->parseArgs(); + if (!count($args)) { + throw new Horde_Controller_Exception('unknown command: ' . implode(' ', $args)); + } + $this->_path = $args[0]; + $this->_path = str_replace('-', '_', $this->_path); + } + } + /** * Get all command line parameters. * some wacky loops to make sure that nested values in one