From bc796fd68e1faae3260c186ac446c3a75ac1ecf5 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sun, 23 May 2010 17:12:20 +0200 Subject: Add FedoraPkgdb->getBranch(), improves fedcli.php --- fedcli.php | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 7 deletions(-) (limited to 'fedcli.php') diff --git a/fedcli.php b/fedcli.php index 1bc48f3..d8439ff 100755 --- a/fedcli.php +++ b/fedcli.php @@ -23,14 +23,72 @@ * See */ -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"; ?> -- cgit