[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pear-cvs
Subject:    [PEAR-CVS] svn: /pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/ CLI.php
From:       Brett_Bieber <saltybeagle () php ! net>
Date:       2009-10-31 12:56:32
Message-ID: svn-saltybeagle-1256993792-290101-76383268 () svn ! php ! net
[Download RAW message or body]

saltybeagle                              Sat, 31 Oct 2009 12:56:32 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=290101

Log:
Get add-category command working from CLI.

Changed paths:
    U   pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/CLI.php

Modified: pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/CLI.php
===================================================================
--- pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/CLI.php	2009-10-31 \
                12:20:37 UTC (rev 290100)
+++ pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/CLI.php	2009-10-31 \
12:56:32 UTC (rev 290101) @@ -46,7 +46,7 @@
                     // yes, new maintainers that have not yet released anything.
                 break;
             case 'add-category':
-                Categories::create($category, $description);
+                $this->handleAddCategory();
                 break;
             case 'release':
                 $this->handleRelease();
@@ -57,25 +57,54 @@
                 break;
         }
     }
+
+    function handleAddCategory()
+    {
+        if ($_SERVER['argc'] < 3) {
+            $this->printCategoryUsage();
+            return false;
+        }

+        $args = array();
+        $args['category']    = $_SERVER['argv'][2];
+        $args['description'] = (isset($_SERVER['argv'][3]))?
+                                    $_SERVER['argv'][3]:$_SERVER['argv'][2];
+
+        Categories::create($args['category'], $args['description']);
+        $category = new REST\Category($this->dir . '/rest', $this->channel->name);
+        $category->saveAllCategories();
+        $category->savePackagesInfo($args['category']);
+        echo "Added category ", $args['category'], "\n";
+    }
+
     function pyrusAddCategory($frontend, $args)
     {
         if (!isset($this->channel)) {
-            throw new Exception('Unknown channel, run the' .
-                                                          'scs-create command \
first'); +            throw new Exception('Unknown channel, run the ' .
+                                'scs-create command first');
         }
+
         Categories::create($args['category'], $args['description']);
         $category = new REST\Category($this->dir . '/rest', $this->channel->name);
         $category->saveAllCategories();
         $category->savePackagesInfo($args['category']);
         echo "Added category ", $args['category'], "\n";
     }
+
+    function printCategoryUsage()
+    {
+        echo 'Usage: pearscs add-category category [description]
+    This will add a category to the current channel.
+
+    category    Name of the category.
+    description Description of the category.' . PHP_EOL;
+    }

     function pyrusAddMaintainer($frontend, $args)
     {
         if (!isset($this->channel)) {
-            throw new Exception('Unknown channel, run the' .
-                                                          'scs-create command \
first'); +            throw new Exception('Unknown channel, run the ' .
+                                'scs-create command first');
         }
         $maintainer = new REST\Maintainer($this->dir . '/rest', \
$this->channel->name);  if (isset($args['uri'])) {
@@ -104,8 +133,8 @@
     function pyrusUpdate($frontend, $args)
     {
         if (!isset($this->channel)) {
-            throw new Exception('Unknown channel, run the' .
-                                                          'scs-create command \
first'); +            throw new Exception('Unknown channel, run the ' .
+                                'scs-create command first');
         }
         if (null === $frontend) {
             $maintainer = $args;
@@ -204,8 +233,8 @@
         }
         $this->dir = dirname($args['file']);
         $this->channel = new Channel($args['name'],
-                                                               $args['summary'],
-                                                               $args['alias']);
+                                     $args['summary'],
+                                     $args['alias']);
         $scs = new Main($this->channel,
             $this->dir);
         $scs->saveChannel();
@@ -247,7 +276,7 @@
         update [channel.xml]                  Update the channel xml files.
         create pear.example.com summary [...] Create a new channel.
         add-maintainer handle                 Add a maintainer.
-        add-category category                 Add a category.
+        add-category category [description]   Add a category.
         release package.tgz maintainer        Release package.
 ';
     }



-- 
PEAR CVS Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic