Commit 0ca4275a authored by Manfred Kutas's avatar Manfred Kutas

ZP-1291 Exit with 0 if gab2contacts called with help.

Released under the Affero GNU General Public License (AGPL) version 3.
parent fe8f9dd5
......@@ -48,6 +48,9 @@ define('PATH_TO_ZPUSH', '../../src/');
fwrite(STDERR, GAB2ContactsCLI::GetErrorMessage() . PHP_EOL.PHP_EOL);
echo GAB2ContactsCLI::UsageInstructions();
if (GAB2ContactsCLI::$help) {
exit(0);
}
exit(1);
}
else if (!GAB2ContactsCLI::SetupContactWorker()) {
......@@ -76,6 +79,8 @@ class GAB2ContactsCLI {
static private $sourceGAB;
static private $errormessage;
static public $help = false;
/**
* Returns usage instructions.
*
......@@ -144,7 +149,7 @@ class GAB2ContactsCLI {
if (self::$errormessage)
return;
$options = getopt("a:");
$options = getopt("a:h", array('help'));
// get 'action'
$action = false;
......@@ -153,6 +158,11 @@ class GAB2ContactsCLI {
elseif (isset($options['action']) && !empty($options['action']))
$action = strtolower(trim($options['action']));
if ((isset($options['h']) || isset($options['help'])) && $action === false) {
self::$help = true;
$action = 'help';
}
// get a command for the requested action
switch ($action) {
// sync!
......@@ -165,8 +175,12 @@ class GAB2ContactsCLI {
self::$command = self::COMMAND_DELETE;
break;
case "help":
break;
default:
self::UsageInstructions();
self::$help = false;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment