Exemplo n.º 1
0
 public function testGetVersion()
 {
     $result = \Comodojo\Extender\Version::getVersion();
     $this->assertInternalType('string', $result);
 }
Exemplo n.º 2
0
 private static function showHelp($color)
 {
     echo Version::getDescription();
     echo "\nVersion: " . $color->convert("%g" . Version::getVersion() . "%n");
     echo "\n\nAvailable options:";
     echo "\n------------------";
     echo "\n" . $color->convert("%g -v %n") . ": verbose mode";
     echo "\n" . $color->convert("%g -V %n") . ": debug mode";
     echo "\n" . $color->convert("%g -s %n") . ": show summary of executed jobs (if any)";
     echo "\n" . $color->convert("%g -d %n") . ": run extender in daemon mode";
     echo "\n" . $color->convert("%g -h %n") . ": show this help";
     echo "\n\n";
 }
Exemplo n.º 3
0
 /**
  * econtrol constructor
  *
  */
 public function __construct()
 {
     // check if econtrol is running from cli
     if (Checks::cli() === false) {
         echo "Econtrol runs only in php-cli, exiting";
         self::end(1);
     }
     if (defined('EXTENDER_TIMEZONE')) {
         date_default_timezone_set(EXTENDER_TIMEZONE);
     }
     $this->color = new Console_Color2();
     $this->parser = new Console_CommandLine(array('description' => Version::getDescription(), 'version' => Version::getVersion()));
     // add verbose option
     $this->parser->addOption('verbose', array('short_name' => '-v', 'long_name' => '--verbose', 'description' => 'turn on verbose output', 'action' => 'StoreTrue'));
     // add debug option
     $this->parser->addOption('debug', array('short_name' => '-V', 'long_name' => '--debug', 'description' => 'turn on debug output', 'action' => 'StoreTrue'));
     try {
         $check_constants = Checks::constants();
         if ($check_constants !== true) {
             throw new ShellException($check_constants);
         }
         if (array_key_exists('V', getopt("V"))) {
             $verbose = 'DEBUG';
             echo $this->color->convert("\n%r(> Debug mode on <)%n\n");
         } else {
             if (array_key_exists('v', getopt("v"))) {
                 $verbose = 'NOTICE';
                 echo $this->color->convert("\n%y(> Verbose mode on <)%n\n");
             } else {
                 $verbose = false;
             }
         }
         $this->logger = EcontrolLogger::create($verbose);
         $this->tasks = TasksTable::load($this->logger);
         $this->controller = Controller::load($this->parser, $this->logger);
     } catch (Console_CommandLine_Exception $ce) {
         $this->parser->displayError($this->color->convert("\n\n%y" . $ce->getMessage() . "%n\n"));
         self::end(1);
     } catch (ShellException $se) {
         $this->parser->displayError($this->color->convert("\n\n%R" . $se->getMessage() . "%n\n"));
         self::end(1);
     } catch (Exception $e) {
         $this->parser->displayError($this->color->convert("\n\n%r" . $e->getMessage() . "%n\n"));
         self::end(1);
     }
 }