mirror of
https://github.com/friendica/friendica
synced 2025-04-26 13:10:11 +00:00
Using getopt for CLI arguments (#5446)
* Adding Argument class to Friendica * Adding Argument class to Friendica * Adding Argument class to Friendica * fixing arguments for `spawnWorker` * Adding `use Friendica\BaseObject` to `ApiTest.php` * Refactoring the argument-usages of Friendica * Refactoring the argument-usages of Friendica * removing superfluous []
This commit is contained in:
parent
ea24ac9d95
commit
cd52d0b3e9
5 changed files with 38 additions and 15 deletions
|
@ -12,6 +12,12 @@ use Friendica\Core\Config;
|
|||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
|
||||
// Get options
|
||||
$shortopts = '';
|
||||
$shortopts .= 'f';
|
||||
$longopts = [ 'foreground' ];
|
||||
$options = getopt($shortopts, $longopts);
|
||||
|
||||
// Ensure that daemon.php is executed from the base path of the installation
|
||||
if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
|
||||
$directory = dirname($_SERVER["argv"][0]);
|
||||
|
@ -55,7 +61,7 @@ if (in_array("status", $_SERVER["argv"])) {
|
|||
$mode = "status";
|
||||
}
|
||||
|
||||
$foreground = in_array("--foreground", $_SERVER["argv"]);
|
||||
$foreground = array_key_exists('f', $options) || array_key_exists('foreground', $options);
|
||||
|
||||
if (!isset($mode)) {
|
||||
die("Please use either 'start', 'stop' or 'status'.\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue