svn: /pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/ CLI.php

From: Date: Sat, 31 Oct 2009 12:56:32 +0000
Subject: svn: /pear2/sandbox/SimpleChannelServer/trunk/src/SimpleChannelServer/ CLI.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-9009@lists.php.net to get a copy of this message
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. '; }

« previous php.pear.core (#9009) next »