Commit a060e7cb authored by Manfred Kutas's avatar Manfred Kutas

ZP-1291 Exit with 0 if z-push-admin called with help.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 1ecfcba2
...@@ -52,6 +52,9 @@ require_once 'vendor/autoload.php'; ...@@ -52,6 +52,9 @@ require_once 'vendor/autoload.php';
fwrite(STDERR, ZPushAdminCLI::GetErrorMessage() . "\n"); fwrite(STDERR, ZPushAdminCLI::GetErrorMessage() . "\n");
echo ZPushAdminCLI::UsageInstructions(); echo ZPushAdminCLI::UsageInstructions();
if (ZPushAdminCLI::$help) {
exit(0);
}
exit(1); exit(1);
} }
...@@ -101,6 +104,8 @@ class ZPushAdminCLI { ...@@ -101,6 +104,8 @@ class ZPushAdminCLI {
static private $folderid = false; static private $folderid = false;
static private $flags = 0; static private $flags = 0;
static public $help = false;
/** /**
* Returns usage instructions * Returns usage instructions
* *
...@@ -172,7 +177,7 @@ class ZPushAdminCLI { ...@@ -172,7 +177,7 @@ class ZPushAdminCLI {
if (self::$errormessage) if (self::$errormessage)
return; return;
$options = getopt("u:d:a:t:sn:o:f:g::", array('user:', 'device:', 'action:', 'type:', 'days-old:', 'days-ago:', 'shared', 'foldername:', 'store', 'folderid:', 'flags::')); $options = getopt("u:d:a:t:sn:o:f:g::h", array('user:', 'device:', 'action:', 'type:', 'days-old:', 'days-ago:', 'shared', 'foldername:', 'store', 'folderid:', 'flags::', 'help'));
// get 'user' // get 'user'
if (isset($options['u']) && !empty($options['u'])) if (isset($options['u']) && !empty($options['u']))
...@@ -269,6 +274,11 @@ class ZPushAdminCLI { ...@@ -269,6 +274,11 @@ class ZPushAdminCLI {
} }
} }
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) {
// list data // list data
...@@ -381,8 +391,12 @@ class ZPushAdminCLI { ...@@ -381,8 +391,12 @@ class ZPushAdminCLI {
self::$command = self::COMMAND_REMOVESHARED; self::$command = self::COMMAND_REMOVESHARED;
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