Commit fe8f9dd5 authored by Manfred Kutas's avatar Manfred Kutas

ZP-1291 Exit with 0 if gab-sync called with help.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 3dbdfd33
...@@ -42,6 +42,9 @@ include_once(SYNC_CONFIG); ...@@ -42,6 +42,9 @@ include_once(SYNC_CONFIG);
fwrite(STDERR, GabSyncCLI::GetErrorMessage() . PHP_EOL.PHP_EOL); fwrite(STDERR, GabSyncCLI::GetErrorMessage() . PHP_EOL.PHP_EOL);
echo GabSyncCLI::UsageInstructions(); echo GabSyncCLI::UsageInstructions();
if (GabSyncCLI::$help) {
exit(0);
}
exit(1); exit(1);
} }
else if (!GabSyncCLI::SetupSyncWorker()) { else if (!GabSyncCLI::SetupSyncWorker()) {
...@@ -74,6 +77,8 @@ class GabSyncCLI { ...@@ -74,6 +77,8 @@ class GabSyncCLI {
static private $targetGab = false; static private $targetGab = false;
static private $errormessage; static private $errormessage;
static public $help = false;
/** /**
* Returns usage instructions. * Returns usage instructions.
* *
...@@ -142,7 +147,7 @@ class GabSyncCLI { ...@@ -142,7 +147,7 @@ class GabSyncCLI {
if (self::$errormessage) if (self::$errormessage)
return; return;
$options = getopt("u:a:t:"); $options = getopt("u:a:t:h", array('help'));
// get 'unique-id' // get 'unique-id'
if (isset($options['u']) && !empty($options['u'])) if (isset($options['u']) && !empty($options['u']))
...@@ -163,6 +168,11 @@ class GabSyncCLI { ...@@ -163,6 +168,11 @@ class GabSyncCLI {
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) {
// simulate // simulate
...@@ -195,8 +205,12 @@ class GabSyncCLI { ...@@ -195,8 +205,12 @@ class GabSyncCLI {
self::$command = self::COMMAND_DELETEALL; self::$command = self::COMMAND_DELETEALL;
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