fix --exit-codes did not found (now used) exceptions

This commit is contained in:
Ralf Becker 2019-02-23 12:11:30 +01:00
parent 78028dfbda
commit d084bd0679

View File

@ -6,9 +6,8 @@
* @link http://www.egroupware.org
* @package setup
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2006-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2006-19 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
@ -117,6 +116,7 @@ switch($action)
list_exit_codes();
break;
case '-h':
case '--help':
case '--usage':
do_usage($arguments[0]);
@ -506,23 +506,15 @@ function do_usage($what='')
}
if (!$what || !in_array($what,array('config','header','list')))
{
echo '--help [config|header|list] '.lang('gives further options')."\n";
echo '--help|-h [config|header|list] '.lang('gives further options')."\n";
}
}
function fail($exit_code,$message)
{
echo $message."\n";
exit($exit_code);
}
/**
* List all exit codes used by the command line interface
*
* The list is generated by "greping" this file for calls to the fail() function.
* Calls to fail() have to be in one line, to be recogniced!
*
* @todo we need to grep for the exceptions too!
* The list is generated by "greping" this file for thrown exceptions.
* Exceptions have to be in one line, to be recogniced!
*/
function list_exit_codes()
{
@ -543,7 +535,7 @@ function list_exit_codes()
$content = file_get_contents($setup_dir.'/'.$file);
$matches = null;
if (preg_match_all('/throw new (egw_exception[a-z_]*)\((.*),([0-9]+)\);/m',$content,$matches))
if (preg_match_all('/throw new (Api\\\\Exception[\\\\a-z_]*)\((.*),([0-9]+)\);/mi',$content,$matches))
{
//echo $file.":\n"; print_r($matches);
foreach($matches[3] as $key => $code)