mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-14 01:34:55 +02:00
Add proper exit() code to bin/ commands
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
if(PHP_SAPI !== 'cli') {
|
||||
die('This script can be run only in command line mode.');
|
||||
echo 'This script can be run only in command line mode.';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../../common.php';
|
||||
@@ -11,17 +12,20 @@ require_once SYSTEM . 'hooks.php';
|
||||
require_once LIBS . 'plugins.php';
|
||||
|
||||
if($argc !== 2) {
|
||||
exit('This command expects one parameter: zip file name (plugin)' . PHP_EOL);
|
||||
echo 'This command expects one parameter: zip file name (plugin)' . PHP_EOL;
|
||||
exit(2);
|
||||
}
|
||||
|
||||
$path_to_file = $argv[1];
|
||||
$ext = strtolower(pathinfo($path_to_file, PATHINFO_EXTENSION));
|
||||
if($ext !== 'zip') {// check if it is zipped/compressed file
|
||||
exit('Please install only .zip files.' . PHP_EOL);
|
||||
echo 'Please install only .zip files.' . PHP_EOL;
|
||||
exit(3);
|
||||
}
|
||||
|
||||
if(!file_exists($path_to_file)) {
|
||||
exit('ERROR: File ' . $path_to_file . ' does not exist' . PHP_EOL);
|
||||
echo 'ERROR: File ' . $path_to_file . ' does not exist' . PHP_EOL;
|
||||
exit(4);
|
||||
}
|
||||
|
||||
if(Plugins::install($path_to_file)) {
|
||||
@@ -30,9 +34,9 @@ if(Plugins::install($path_to_file)) {
|
||||
}
|
||||
|
||||
$info = Plugins::getPlugin();
|
||||
echo (isset($info['name']) ? $info['name'] . ' p' : 'P') . 'lugin has been successfully installed.';
|
||||
echo (isset($info['name']) ? $info['name'] . ' p' : 'P') . 'lugin has been successfully installed.' . PHP_EOL;
|
||||
}
|
||||
else {
|
||||
echo 'ERROR: ' . Plugins::getError() . PHP_EOL;
|
||||
exit(5);
|
||||
}
|
||||
else
|
||||
echo 'ERROR: ' . Plugins::getError();
|
||||
|
||||
echo PHP_EOL;
|
Reference in New Issue
Block a user