summaryrefslogtreecommitdiffstats
path: root/fedcli.php
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2010-05-23 17:12:20 +0200
committerRemi Collet <fedora@famillecollet.com>2010-05-23 17:12:20 +0200
commitbc796fd68e1faae3260c186ac446c3a75ac1ecf5 (patch)
tree778ca8c2177b81c229f9c9520704cd4b43d01a0d /fedcli.php
parent9cc3e2d35597302a3c831c5787cd18b90218b434 (diff)
Add FedoraPkgdb->getBranch(), improves fedcli.php
Diffstat (limited to 'fedcli.php')
-rwxr-xr-xfedcli.php72
1 files changed, 65 insertions, 7 deletions
diff --git a/fedcli.php b/fedcli.php
index 1bc48f3..d8439ff 100755
--- a/fedcli.php
+++ b/fedcli.php
@@ -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";
?>