Commit 31d436d0 authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #671 in ZP/z-push from...

Merge pull request #671 in ZP/z-push from bugfix/ZP-1291-cli-tools-should-exit-with-0-if-called-with-help to develop

* commit '0ca4275a':
  ZP-1291 Exit with 0 if gab2contacts called with help.
  ZP-1291 Exit with 0 if gab-sync called with help.
  ZP-1291 Exit with 0 if z-push-top called with help.
  ZP-1291 Exit with 0 if z-push-admin called with help.
parents 1ecfcba2 0ca4275a
......@@ -52,6 +52,9 @@ require_once 'vendor/autoload.php';
fwrite(STDERR, ZPushAdminCLI::GetErrorMessage() . "\n");
echo ZPushAdminCLI::UsageInstructions();
if (ZPushAdminCLI::$help) {
exit(0);
}
exit(1);
}
......@@ -101,6 +104,8 @@ class ZPushAdminCLI {
static private $folderid = false;
static private $flags = 0;
static public $help = false;
/**
* Returns usage instructions
*
......@@ -172,7 +177,7 @@ class ZPushAdminCLI {
if (self::$errormessage)
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'
if (isset($options['u']) && !empty($options['u']))
......@@ -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
switch ($action) {
// list data
......@@ -381,8 +391,12 @@ class ZPushAdminCLI {
self::$command = self::COMMAND_REMOVESHARED;
break;
case "help":
break;
default:
self::UsageInstructions();
self::$help = false;
}
}
......
......@@ -51,7 +51,7 @@ require_once 'vendor/autoload.php';
// check if help was requested from CLI
if (in_array('-h', $argv) || in_array('--help', $argv)) {
echo $zpt->UsageInstructions();
exit(1);
exit(0);
}
if ($zpt->IsAvailable()) {
......
......@@ -42,6 +42,9 @@ include_once(SYNC_CONFIG);
fwrite(STDERR, GabSyncCLI::GetErrorMessage() . PHP_EOL.PHP_EOL);
echo GabSyncCLI::UsageInstructions();
if (GabSyncCLI::$help) {
exit(0);
}
exit(1);
}
else if (!GabSyncCLI::SetupSyncWorker()) {
......@@ -74,6 +77,8 @@ class GabSyncCLI {
static private $targetGab = false;
static private $errormessage;
static public $help = false;
/**
* Returns usage instructions.
*
......@@ -142,7 +147,7 @@ class GabSyncCLI {
if (self::$errormessage)
return;
$options = getopt("u:a:t:");
$options = getopt("u:a:t:h", array('help'));
// get 'unique-id'
if (isset($options['u']) && !empty($options['u']))
......@@ -163,6 +168,11 @@ class GabSyncCLI {
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) {
// simulate
......@@ -195,8 +205,12 @@ class GabSyncCLI {
self::$command = self::COMMAND_DELETEALL;
break;
case "help":
break;
default:
self::UsageInstructions();
self::$help = false;
}
}
......
......@@ -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