diff options
author | Remi Collet <fedora@famillecollet.com> | 2010-05-23 17:12:20 +0200 |
---|---|---|
committer | Remi Collet <fedora@famillecollet.com> | 2010-05-23 17:12:20 +0200 |
commit | bc796fd68e1faae3260c186ac446c3a75ac1ecf5 (patch) | |
tree | 778ca8c2177b81c229f9c9520704cd4b43d01a0d /fedcli.php | |
parent | 9cc3e2d35597302a3c831c5787cd18b90218b434 (diff) |
Add FedoraPkgdb->getBranch(), improves fedcli.php
Diffstat (limited to 'fedcli.php')
-rwxr-xr-x | fedcli.php | 72 |
1 files changed, 65 insertions, 7 deletions
@@ -23,14 +23,72 @@ * See <http://www.gnu.org/licenses/> */ -require('FedoraClient.php'); +require 'Console/Getargs.php'; +require 'FedoraClient.php'; -$client = new FedoraPkgdb(array('debug'=>2)); +function Help() { + echo "\nFedora Client Command Line usage\n\n"; + + echo "fdcli command options\n"; + echo "\tbranches: list branches\n"; + echo "\tversion: class version\n"; + echo "Also try fdcli command --help\n"; +} + +function Branches() { + $config = array( + "debug" => array('short' => 'd', 'max' => 1, 'min' => 1, 'desc' => "debug level", 'default' => "0") + ); + $args =& Console_Getargs::factory($config); + + if (PEAR::isError($args)) { + die (Console_Getargs::getHelp($config)); + } + + $client = new FedoraPkgdb(array('debug' => intval($args->getValue('debug')))); + $branches = $client->getBranches(); + foreach ($branches as $name => $branch) { + echo $name." "; + } + echo "\n"; +} + +function Branch() { + $config = array( + "branch" => array('short' => 'b', 'max' => 1, 'min' => 1, 'desc' => "branch name", 'default' => "devel"), + "debug" => array('short' => 'd', 'max' => 1, 'min' => 1, 'desc' => "debug level", 'default' => "0") + ); + $args =& Console_Getargs::factory($config); + + if (PEAR::isError($args)) { + die (Console_Getargs::getHelp($config)); + } + + $client = new FedoraPkgdb(array('debug' => intval($args->getValue('debug')))); + $branch = $client->getBranch($args->getValue('branch')); + print_r($branch); +} + +function Version() { + $config = array( + "debug" => array('short' => 'd', 'max' => 1, 'min' => 1, 'desc' => "debug level", 'default' => "0") + ); + $args =& Console_Getargs::factory($config); + + if (PEAR::isError($args)) { + die (Console_Getargs::getHelp($config)."\n"); + } + + echo "PHP Fedora Client class version ".FEDORACLIENT_VERSION."\n"; +} + +$cmd = array_shift($_SERVER['argv']); +$cmd = array_shift($_SERVER['argv']); -echo "FedoraPkgdb::getBranches():\n"; -$branches = $client->getBranches(); -foreach ($branches as $name => $branch) { - echo $name." "; +switch ($cmd) { + case 'branches': Branches(); break; + case 'branch': Branch(); break; + case 'version': Version(); break; + default: Help(); } -echo "\ndone.\n"; ?> |