Example #1
0
 /**
  * 执行动作
  * @param array $args 命令行参数
  * @return integer 非0的应用退出码
  */
 public function run($args)
 {
     $runner = $this->getCommandRunner();
     $commands = $runner->commands;
     if (isset($args[0])) {
         $name = strtolower($args[0]);
     }
     if (!isset($args[0]) || !isset($commands[$name])) {
         if (!empty($commands)) {
             echo "Sky command runner (based on Sky v" . Sky::getVersion() . ")\n";
             echo "Usage: " . $runner->getScriptName() . " <command-name> [parameters...]\n";
             echo "\nThe following commands are available:\n";
             $commandNames = array_keys($commands);
             sort($commandNames);
             echo ' - ' . implode("\n - ", $commandNames);
             echo "\n\nTo see individual command help, use the following:\n";
             echo "   " . $runner->getScriptName() . " help <command-name>\n";
         } else {
             echo "No available commands.\n";
             echo "Please define them under the following directory:\n";
             echo "\t" . Sky::$app->getCommandPath() . "\n";
         }
     } else {
         echo $runner->createCommand($name)->getHelp();
     }
     return 1;
 }
Example #2
0
 /**
  * 返回服务器软件版本信息
  * 如果应用部署在生产模式,将返回空字符
  * @return string
  */
 protected function getVersionInfo()
 {
     if (SKY_DEBUG) {
         $version = '<a href="http://www.skyworth.com/">SKY Framework</a>/' . \Sky\Sky::getVersion();
         if (isset($_SERVER['SERVER_SOFTWARE'])) {
             $version = $_SERVER['SERVER_SOFTWARE'] . ' ' . $version;
         }
     } else {
         $version = '';
     }
     return $version;
 }