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/'); ...@@ -48,6 +48,9 @@ define('PATH_TO_ZPUSH', '../../src/');
fwrite(STDERR, GAB2ContactsCLI::GetErrorMessage() . PHP_EOL.PHP_EOL); fwrite(STDERR, GAB2ContactsCLI::GetErrorMessage() . PHP_EOL.PHP_EOL);
echo GAB2ContactsCLI::UsageInstructions(); echo GAB2ContactsCLI::UsageInstructions();
if (GAB2ContactsCLI::$help) {
exit(0);
}
exit(1); exit(1);
} }
else if (!GAB2ContactsCLI::SetupContactWorker()) { else if (!GAB2ContactsCLI::SetupContactWorker()) {
...@@ -76,6 +79,8 @@ class GAB2ContactsCLI { ...@@ -76,6 +79,8 @@ class GAB2ContactsCLI {
static private $sourceGAB; static private $sourceGAB;
static private $errormessage; static private $errormessage;
static public $help = false;
/** /**
* Returns usage instructions. * Returns usage instructions.
* *
...@@ -144,7 +149,7 @@ class GAB2ContactsCLI { ...@@ -144,7 +149,7 @@ class GAB2ContactsCLI {
if (self::$errormessage) if (self::$errormessage)
return; return;
$options = getopt("a:"); $options = getopt("a:h", array('help'));
// get 'action' // get 'action'
$action = false; $action = false;
...@@ -153,6 +158,11 @@ class GAB2ContactsCLI { ...@@ -153,6 +158,11 @@ class GAB2ContactsCLI {
elseif (isset($options['action']) && !empty($options['action'])) elseif (isset($options['action']) && !empty($options['action']))
$action = strtolower(trim($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 // get a command for the requested action
switch ($action) { switch ($action) {
// sync! // sync!
...@@ -165,8 +175,12 @@ class GAB2ContactsCLI { ...@@ -165,8 +175,12 @@ class GAB2ContactsCLI {
self::$command = self::COMMAND_DELETE; self::$command = self::COMMAND_DELETE;
break; break;
case "help":
break;
default: default:
self::UsageInstructions(); 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