#!/usr/bin/php parent::ARGS, "purpose" => "lancer une tâche de fond", "usage" => "ApplicationClass args...", ["-s", "--start", "name" => "action", "value" => self::ACTION_START, "help" => "démarrer la tâche, c'est la valeur par défaut" ], ["-k", "--stop", "name" => "action", "value" => self::ACTION_STOP, "help" => "arrêter la tâche" ], ["-i", "--infos", "name" => "action", "value" => self::ACTION_INFOS, "help" => "afficher des informations sur la tâche" ], ]; protected $action = self::ACTION_START; protected $args; function main() { $appClass = $this->args[0] ?? null; if ($appClass === null) { self::die("Vous devez spécifier la classe de l'application"); } elseif (!class_exists($appClass)) { self::die("$appClass: Cette classe n'existe pas"); } $args = array_slice($this->args, 1); $useRunfile = constant("$appClass::USE_RUNFILE"); if (!$useRunfile) { self::die("Cette application ne supporte pas l'usage de runfile"); } $runfile = app::with($appClass, self::$internal_use_app_params)->getRunfile(); switch ($this->action) { case self::ACTION_START: launcher::_start($args, $runfile); break; case self::ACTION_STOP: launcher::_stop($runfile); break; case self::ACTION_INFOS: yaml::dump($runfile->read()); break; } } } _LaunchApp::internal_use_set_app_params($app_params); _LaunchApp::run();