From be9f96e74ef96c85ef0b9c11c30f220c140ad48a Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sun, 17 Nov 2013 17:46:48 +0100 Subject: WIP for pkgdb2 --- fedcli.php | 66 ++++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 23 deletions(-) (limited to 'fedcli.php') diff --git a/fedcli.php b/fedcli.php index a604ae8..0588caf 100755 --- a/fedcli.php +++ b/fedcli.php @@ -5,7 +5,7 @@ * * fedcli.php is a command line tools to test FedoraClient clmsses * - * Copyright (C) 2010 Remi Collet + * Copyright (C) 2010-2013 Remi Collet * http://github.com/remicollet/rpmphp. * * Inspired from python-fedora @@ -42,7 +42,9 @@ function Help() { function Branches() { $config = array( - "debug" => array('short' => 'd', 'max' => 1, 'min' => 1, 'desc' => "debug level", 'default' => "0") + "server" => array('short' => 's', 'max' => 1, 'min' => 1, 'desc' => "server URL", 'default' => ""), + "debug" => array('short' => 'd', 'max' => 1, 'min' => 1, 'desc' => "debug level", 'default' => "0"), + "refresh" => array('short' => 'r', 'max' => 1, 'min' => 1, 'desc' => "refresh cache", 'default' => "0"), ); $args =& Console_Getargs::factory($config); @@ -50,8 +52,9 @@ function Branches() { die (Console_Getargs::getHelp($config)); } - $client = new FedoraPkgdb(array('debug' => intval($args->getValue('debug')))); - $branches = $client->getBranches(); + $client = new FedoraPkgdb(array('debug' => intval($args->getValue('debug')), + 'server' => $args->getValue('server'))); + $branches = $client->getBranches(intval($args->getValue('refresh'))); foreach ($branches as $name => $branch) { echo $name." "; } @@ -60,8 +63,10 @@ function Branches() { 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") + "server" => array('short' => 's', 'max' => 1, 'min' => 1, 'desc' => "server URL", 'default' => ""), + "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"), + "refresh" => array('short' => 'r', 'max' => 1, 'min' => 1, 'desc' => "refresh cache", 'default' => "0"), ); $args =& Console_Getargs::factory($config); @@ -69,15 +74,18 @@ function Branch() { die (Console_Getargs::getHelp($config)); } - $client = new FedoraPkgdb(array('debug' => intval($args->getValue('debug')))); - $branch = $client->getBranch($args->getValue('branch')); + $client = new FedoraPkgdb(array('debug' => intval($args->getValue('debug')), + 'server' => $args->getValue('server'))); + $branch = $client->getBranch($args->getValue('branch'), intval($args->getValue('refresh'))); print_r($branch); } function CritPath() { $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") + "server" => array('short' => 's', 'max' => 1, 'min' => 1, 'desc' => "server URL", 'default' => ""), + "debug" => array('short' => 'd', 'max' => 1, 'min' => 1, 'desc' => "debug level", 'default' => "0"), + "refresh" => array('short' => 'r', 'max' => 1, 'min' => 1, 'desc' => "refresh cache", 'default' => "0"), ); $args =& Console_Getargs::factory($config); @@ -85,23 +93,29 @@ function CritPath() { die (Console_Getargs::getHelp($config)); } - $client = new FedoraPkgdb(array('debug' => intval($args->getValue('debug')))); - $branch = $client->getCritPath(); - print_r($branch); + $client = new FedoraPkgdb(array('debug' => intval($args->getValue('debug')), + 'server' => $args->getValue('server'))); + $crit = $client->getCritPath(intval($args->getValue('refresh'))); + foreach ($crit as $name => $pkgs) { + echo "\n$name: ".implode(', ', $pkgs)."\n"; + } } function Package() { $config = array( + "server" => array('short' => 's', 'max' => 1, 'min' => 1, 'desc' => "server URL", 'default' => ""), "package" => array('short' => 'p', 'max' => 1, 'min' => 1, 'desc' => "package name"), - "debug" => array('short' => 'd', 'max' => 1, 'min' => 1, 'desc' => "debug level", 'default' => "0") + "debug" => array('short' => 'd', 'max' => 1, 'min' => 1, 'desc' => "debug level", 'default' => "0"), + "refresh" => array('short' => 'r', 'max' => 1, 'min' => 1, 'desc' => "refresh cache", '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')))); - $rep = $client->getPackageInfo($args->getValue('package')); + $client = new FedoraPkgdb(array('debug' => intval($args->getValue('debug')), + 'server' => $args->getValue('server'))); + $rep = $client->getPackageInfo($args->getValue('package'), intval($args->getValue('refresh'))); if (!$rep) { die("Package not found\n"); @@ -136,7 +150,8 @@ function Package() { function Version() { $config = array( - "debug" => array('short' => 'd', 'max' => 1, 'min' => 1, 'desc' => "debug level", 'default' => "0") + "server" => array('short' => 's', 'max' => 1, 'min' => 1, 'desc' => "server URL", 'default' => ""), + "debug" => array('short' => 'd', 'max' => 1, 'min' => 1, 'desc' => "debug level", 'default' => "0") ); $args =& Console_Getargs::factory($config); @@ -145,17 +160,22 @@ function Version() { } echo "PHP Fedora Client class version ".FedoraClient::VERSION."\n"; + $client = new FedoraPkgdb(array('debug' => intval($args->getValue('debug')), + 'server' => $args->getValue('server'))); + echo "pkgdb version ".$client->getVersion()."\n"; } +error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT); + $cmd = array_shift($_SERVER['argv']); $cmd = array_shift($_SERVER['argv']); switch ($cmd) { - case 'branches': Branches(); break; - case 'branch': Branch(); break; - case 'critpath': CritPath(); break; - case 'package': Package(); break; - case 'version': Version(); break; - default: Help(); + case 'branches' : Branches(); break; + case 'branch' : Branch(); break; + case 'critpath' : CritPath(); break; + case 'package' : Package(); break; + case 'version' : Version(); break; + default : Help(); } -?> + -- cgit