#!/usr/bin/php */ require 'Console/Getargs.php'; require 'FedoraClient.php'; 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']); switch ($cmd) { case 'branches': Branches(); break; case 'branch': Branch(); break; case 'version': Version(); break; default: Help(); } ?>