1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
#!/usr/bin/php
<?php
/*
* FedoraClient is a PHP classe to interact with web services
*
* fedcli.php is a command line tools to test FedoraClient clmsses
*
* Copyright (C) 2010 Remi Collet
* http://github.com/remicollet/rpmphp.
*
* Inspired from python-fedora
*
* FedoraClient is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* python-fedora is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* See <http://www.gnu.org/licenses/>
*/
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();
}
?>
|