示例#1
0
 /**
  * Handle all data and output result.
  *
  * @throws Exception
  * @return mixed
  */
 public function getOutput()
 {
     print ConsoleUtil::infoLine('>>> Phalconkit Commands Manager v.1.0', false, 1);
     // Not arguments?
     if (!isset($_SERVER['argv'][1])) {
         $this->printAvailableCommands();
         die;
     }
     // Check if 'help' command was used.
     if ($this->_helpIsRequired()) {
         return;
     }
     // Try to dispatch the command.
     if ($cmd = $this->_getRequiredCommand()) {
         return $cmd->dispatch();
     }
     // Check for alternatives.
     $available = [];
     foreach ($this->_commands as $command) {
         $providedCommands = $command->getCommands();
         foreach ($providedCommands as $command) {
             $soundex = soundex($command);
             if (!isset($available[$soundex])) {
                 $available[$soundex] = [];
             }
             $available[$soundex][] = $command;
         }
     }
     // Show exception with/without alternatives.
     $soundex = soundex($_SERVER['argv'][1]);
     if (isset($available[$soundex])) {
         print ConsoleUtil::warningLine('Command "' . $_SERVER['argv'][1] . '" not found. Did you mean: ' . join(' or ', $available[$soundex]) . '?');
         $this->printAvailableCommands();
     } else {
         print ConsoleUtil::warningLine('Command "' . $_SERVER['argv'][1] . '" not found.');
         $this->printAvailableCommands();
     }
 }
示例#2
0
 /**
  * Print special info message.
  *
  * @param string $msg Info message.
  *
  * @return void
  */
 protected function _info($msg)
 {
     print ConsoleUtil::infoLine($msg, false, 0, ConsoleUtil::FG_CYAN);
 }
示例#3
0
文件: Cli.php 项目: biggtfish/cms
 /**
  * Handle all data and output result.
  *
  * @throws Exception
  * @return mixed
  */
 public function getOutput()
 {
     print ConsoleUtil::infoLine('================================================================', true, 0);
     print ConsoleUtil::infoLine("\n           ___  __       __              ____\n          / _ \\/ / ___ _/ _______  ___  / ____ _____\n         / ___/ _ / _ `/ / __/ _ \\/ _ \\/ _// // / -_)\n        /_/  /_//_\\_,_/_/\\__/\\___/_//_/___/\\_, /\\__/\n                                          /___/\n                                          Commands Manager", false, 1);
     print ConsoleUtil::infoLine('================================================================', false, 2);
     // Installation is required.
     if (!$this->_config->installed) {
         print ConsoleUtil::error('Please, install system first.') . PHP_EOL;
         die;
     }
     // Not arguments?
     if (!isset($_SERVER['argv'][1])) {
         $this->printAvailableCommands();
         die;
     }
     // Check if 'help' command was used.
     if ($this->_helpIsRequired()) {
         return;
     }
     // Try to dispatch the command.
     if ($cmd = $this->_getRequiredCommand()) {
         return $cmd->dispatch();
     }
     // Check for alternatives.
     $available = [];
     foreach ($this->_commands as $command) {
         $providedCommands = $command->getCommands();
         foreach ($providedCommands as $command) {
             $soundex = soundex($command);
             if (!isset($available[$soundex])) {
                 $available[$soundex] = [];
             }
             $available[$soundex][] = $command;
         }
     }
     // Show exception with/without alternatives.
     $soundex = soundex($_SERVER['argv'][1]);
     if (isset($available[$soundex])) {
         print ConsoleUtil::warningLine('Command "' . $_SERVER['argv'][1] . '" not found. Did you mean: ' . join(' or ', $available[$soundex]) . '?');
         $this->printAvailableCommands();
     } else {
         print ConsoleUtil::warningLine('Command "' . $_SERVER['argv'][1] . '" not found.');
         $this->printAvailableCommands();
     }
 }