abort if there is no command name (positional argument) to the cli controller
authorChuck Hagenbuch <chuck@horde.org>
Tue, 7 Apr 2009 19:52:45 +0000 (15:52 -0400)
committerChuck Hagenbuch <chuck@horde.org>
Sun, 12 Apr 2009 00:30:11 +0000 (20:30 -0400)
framework/Controller/lib/Horde/Controller/Request/Cli.php

index 7f46a59..b26a89e 100644 (file)
@@ -36,10 +36,12 @@ class Horde_Controller_Request_Cli extends Horde_Controller_Request_Base
     {
         parent::__construct($options);
 
-        $parser = new Horde_Argv_Parser(array('allowUnknownArgs' => true));
+        $parser = new Horde_Argv_Parser(array(
+            'allowUnknownArgs' => true,
+        ));
         list($this->_argv, $args) = $parser->parseArgs();
-        if (count($args) != 1) {
-            throw new Horde_Controller_Exception("unknown command: " . implode(' ', $args));
+        if (!count($args)) {
+            throw new Horde_Controller_Exception('unknown command: ' . implode(' ', $args));
         }
         $this->_path = $args[0];
     }