* * @package Ninaca * @author Nivl * @started 09/01/2009, 01:29 AM * @last Nivl 05/05/2010, 03:16 PM * @link http://nivl.free.fr * @copyright Copyright (C) 2009 Laplanche Melvin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see .
Пример #1
0
 private function render_cli_error($heading, array $messages, $traces = [])
 {
     $cli = new Cli();
     $cli->error(sprintf('<underline><bold>%s</bold></underline>', $heading));
     foreach ($messages as $label => $message) {
         $cli->error(sprintf('%s : <bold>%s</bold>', $label, $message));
     }
     if ($traces) {
         $cli->br()->error('<underline><bold>Backtrace</bold></underline>');
         $i = 1;
         foreach ($traces as $error) {
             $line = isset($error['line']) ? $error['line'] : 'Unknown';
             if (isset($error['file'])) {
                 $console->out(' ' . $i . ') ' . str_replace(FCPATH, './', $error['file']) . ':' . $line);
             } else {
                 $i--;
             }
             $func = '';
             if (isset($error['class'], $error['type'])) {
                 $func .= $error['class'] . $error['type'];
             }
             $func .= $error['function'];
             $console->error('    ' . $func . '()');
             $i++;
         }
     }
 }
Пример #2
0
 /** @test */
 public function shoulLoadCliCommand()
 {
     $kernel = $this->mockFactory->getKernelMock(array('log'));
     $cli = new Cli($kernel);
     $kernel->expects($this->at(2))->method('log')->with($this->stringContains('Done'));
     $cli->handle(array('c' => 'widget.WithCli.simple'));
 }
Пример #3
0
 /**
  * Main method.
  */
 public static function main()
 {
     list($command, $arguments, $config) = self::preProcess();
     $migration = new Migration($config);
     try {
         $cli = new Cli();
         $cli->execute($migration, $command, $arguments, $config);
     } catch (\Exception $e) {
         $debug = $migration->getConfig()->get('debug');
         $colors = $migration->getConfig()->get('colors');
         if (isset($debug) && $debug) {
             if ($colors) {
                 fputs(STDERR, pack('c', 0x1b) . "[1;37;41m" . $e . pack('c', 0x1b) . "[0m\n");
             } else {
                 fputs(STDERR, $e);
             }
         } else {
             if ($colors) {
                 fputs(STDERR, pack('c', 0x1b) . "[1;37;41m" . $e->getMessage() . pack('c', 0x1b) . "[0m\n");
             } else {
                 fputs(STDERR, $e->getMessage() . "\n");
             }
         }
     }
 }
Пример #4
0
 /**
  * @return void
  * @covers \pFlow\Cli<extended>
  * @group pflow
  * @group unittest
  */
 public function testRun()
 {
     $_SERVER['argv'] = array('pflow', '--recursive', 'some_path');
     $analyzerMock = $this->getMock('\\pFlow\\AnalyzerInterface');
     $analyzerMock->expects($this->once())->method('setSources')->with($this->equalTo(array('some_path')), $this->isTrue());
     $cli = new Cli($analyzerMock, new \ezcConsoleInput());
     $cli->run();
 }
Пример #5
0
 /**
  * @expectedException RuntimeException
  */
 public function testException()
 {
     $cli = new Cli();
     $cli->setTempDir(sys_get_temp_dir());
     $cli->setLogger($this->getMockBuilder('Monolog\\Logger')->disableOriginalConstructor()->getMock());
     $code = Code::fromString('throw new \\Exception("test");');
     $result = $cli->run($code);
 }
Пример #6
0
 public static function getInstance()
 {
     if (!self::$obj) {
         self::$obj = new self();
     }
     return self::$obj;
 }
Пример #7
0
 public static function show_php_error(\Exception $e)
 {
     $data['type'] = get_class($e);
     $data['severity'] = $e->getCode();
     $data['message'] = $e->getMessage();
     $data['filepath'] = $e->getFile();
     $data['error_line'] = $e->getLine();
     $data['backtrace'] = $e->getTrace();
     $data['severity'] = !isset(static::$levels[$data['severity']]) ? $data['severity'] : static::$levels[$data['severity']];
     if (\Fuel::$is_cli) {
         \Cli::write(\Cli::color($data['severity'] . ' - ' . $data['message'] . ' in ' . \Fuel::clean_path($data['filepath']) . ' on line ' . $data['error_line'], 'red'));
         return;
     }
     $debug_lines = array();
     foreach ($data['backtrace'] as $key => $trace) {
         if (!isset($trace['file'])) {
             unset($data['backtrace'][$key]);
         } elseif ($trace['file'] == COREPATH . 'classes/error.php') {
             unset($data['backtrace'][$key]);
         }
     }
     $debug_lines = array('file' => $data['filepath'], 'line' => $data['error_line']);
     $data['severity'] = !isset(static::$levels[$data['severity']]) ? $data['severity'] : static::$levels[$data['severity']];
     $data['debug_lines'] = \Debug::file_lines($debug_lines['file'], $debug_lines['line']);
     $data['filepath'] = \Fuel::clean_path($debug_lines['file']);
     $data['filepath'] = str_replace("\\", "/", $data['filepath']);
     $data['error_line'] = $debug_lines['line'];
     echo \View::factory('errors' . DS . 'php_error', $data);
 }
Пример #8
0
 public static function init($args)
 {
     try {
         if (!isset($args[1])) {
             static::help();
             return;
         }
         switch ($args[1]) {
             case 'g':
             case 'generate':
                 switch ($args[2]) {
                     case 'controller':
                     case 'model':
                     case 'view':
                     case 'views':
                     case 'migration':
                         call_user_func('Oil\\Generate::' . $args[2], array_slice($args, 3));
                         break;
                     case 'scaffold':
                         call_user_func('Oil\\Scaffold::generate', array_slice($args, 3));
                         break;
                     default:
                         Generate::help();
                 }
                 break;
             case 'c':
             case 'console':
                 new Console();
             case 'r':
             case 'refine':
                 $task = isset($args[2]) ? $args[2] : null;
                 call_user_func('Oil\\Refine::run', $task, array_slice($args, 3));
                 break;
             case 'p':
             case 'package':
                 switch ($args[2]) {
                     case 'install':
                     case 'uninstall':
                         call_user_func_array('Oil\\Package::' . $args[2], array_slice($args, 3));
                         break;
                     default:
                         Package::help();
                 }
                 break;
             case '-v':
             case '--version':
                 \Cli::write('Fuel: ' . \Fuel::VERSION);
                 break;
             case 'test':
                 \Fuel::add_package('octane');
                 call_user_func('\\Fuel\\Octane\\Tests::run_' . $args[2], array_slice($args, 3));
                 break;
             default:
                 static::help();
         }
     } catch (Exception $e) {
         \Cli::write(\Cli::color('Error: ' . $e->getMessage(), 'light_red'));
         \Cli::beep();
     }
 }
Пример #9
0
 /**
  * ChallengeAbstract constructor.
  */
 public function __construct()
 {
     if (!Cli::isCli()) {
         throw new \DomainException('This challenge is supposed to be run from cli');
     }
     $this->solve();
 }
 /**
  * Run the credential importer
  * 
  * @param string $json_file The JSON file that contains a list of the APIs and their credentials
  */
 public static function run($json_file = null)
 {
     if (empty($json_file) || file_exists($json_file) === false) {
         exit('You must specify a valid JSON file that contains your credentials.' . PHP_EOL);
     }
     if (($json = json_decode(file_get_contents($json_file), true)) === null) {
         exit('The JSON file does not contain valid JSON text.' . PHP_EOL);
     }
     // Find the API version to use for importing the keys
     $version = 'V1';
     if (!empty($json[0]['version'])) {
         if (is_int($json[0]['version']) && \Module::exists('V' . $json[0]['version'])) {
             \Module::load('V' . $json[0]['version']);
             $version = 'V' . $json[0]['version'];
         } else {
             \Module::load($version);
         }
         array_shift($json);
     } else {
         \Module::load($version);
     }
     $error = false;
     foreach ($json as $entry) {
         // We need these keys for each entry.
         if (!array_key_exists('api', $entry) || !array_key_exists('credentials', $entry)) {
             echo \Cli::color('The JSON data is in the wrong format. Skipping.' . PHP_EOL, 'yellow');
             $error = true;
             continue;
         }
         if (!is_string($entry['api'])) {
             echo \Cli::color('The API name must be a string. Skipping.' . PHP_EOL, 'yellow');
             $error = true;
             continue;
         }
         // Make sure that we have credentials to add to the DB.
         if (empty($entry['credentials']) || !is_array($entry['credentials'])) {
             echo \Cli::color('The array of credentials for ' . $entry['api'] . ' is empty. Skipping.' . PHP_EOL, 'yellow');
             $error = true;
             continue;
         }
         $response = call_user_func('\\' . $version . '\\Keyring::set_credentials', $entry['credentials'], $entry['api']);
         // Show and log the result
         if ($response === true) {
             $success_text = 'Successfully imported the credentials for API: ' . $entry['api'];
             echo \Cli::color($success_text . PHP_EOL, 'green');
             \Log::logger('INFO', 'CLI:ADD_CREDENTIALS', $success_text, __METHOD__, array('api' => $entry['api']));
         } else {
             $error_text = 'Failed to import the credentials for API: ' . $entry['api'];
             echo \Cli::color('Warning: ' . $error_text . PHP_EOL, 'red');
             $error = true;
             \Log::logger('ERROR', 'CLI:ADD_CREDENTIALS', $error_text, __METHOD__, array('api' => $entry['api']));
         }
     }
     // Display the summary.
     if ($error === true) {
         echo \Cli::color(PHP_EOL . 'Some credentials were not added to the database. See the error log for more details.' . PHP_EOL, 'red');
     } else {
         echo \Cli::color(PHP_EOL . 'All credentials were successfully added to the database.' . PHP_EOL, 'green');
     }
 }
Пример #11
0
 public static function receive_sqs_for_multi()
 {
     $t1 = microtime(true);
     $pcount = 3;
     $pstack = array();
     for ($i = 1; $i <= $pcount; $i++) {
         $pid = pcntl_fork();
         if ($pid == -1) {
             die('fork できません');
         } else {
             if ($pid) {
                 // 親プロセスの場合
                 $pstack[$pid] = true;
                 if (count($pstack) >= $pcount) {
                     unset($pstack[pcntl_waitpid(-1, $status, WUNTRACED)]);
                 }
             } else {
                 sleep(1);
                 self::receive_sqs_message();
                 exit;
                 //処理が終わったらexitする。
             }
         }
     }
     //先に処理が進んでしまうので待つ
     while (count($pstack) > 0) {
         unset($pstack[pcntl_waitpid(-1, $status, WUNTRACED)]);
     }
     $t2 = microtime(true);
     $process_time = $t2 - $t1;
     \Cli::write("Process time = " . $process_time);
 }
 public function monitor($file, $channel)
 {
     if (false === ($fp = @fopen($file, "r"))) {
         Cli::error("Failed to open {$file}");
     } else {
         Cli::out("Monitoring file: {$file}");
     }
     while (1) {
         if (-1 === fseek($fp, 0, SEEK_END) or !($pos = ftell($fp))) {
             goto retry;
         }
         if ($this->lastPosition === null or $this->lastPosition > $pos) {
             $this->lastPosition = $pos;
             goto retry;
         }
         if ($this->lastPosition < $pos) {
             fseek($fp, $this->lastPosition - $pos, SEEK_CUR);
             if (false === ($content = fread($fp, $pos - $this->lastPosition))) {
                 goto retry;
             }
             try {
                 $this->client->send($content, $channel);
             } catch (\Exception $ex) {
                 Cli::error($ex->getMessage());
             }
             $this->lastPosition = $pos;
         }
         retry:
         usleep(200000);
     }
 }
Пример #13
0
 public static function run($task, $args)
 {
     // Make sure something is set
     if ($task === null or $task === 'help') {
         static::help();
         return;
     }
     // Just call and run() or did they have a specific method in mind?
     list($task, $method) = array_pad(explode(':', $task), 2, 'run');
     $task = ucfirst(strtolower($task));
     // Find the task
     if (!($file = \Fuel::find_file('tasks', $task))) {
         throw new Exception(sprintf('Task "%s" does not exist.', $task));
         return;
     }
     require $file;
     $task = '\\Fuel\\Tasks\\' . $task;
     $new_task = new $task();
     // The help option hs been called, so call help instead
     if (\Cli::option('help') && is_callable(array($new_task, 'help'))) {
         $method = 'help';
     }
     if ($return = call_user_func_array(array($new_task, $method), $args)) {
         \Cli::write($return);
     }
 }
Пример #14
0
 /**
  * @param string $msg A message to display before exiting
  *
  * @author Panagiotis Vagenas <*****@*****.**>
  * @since  0-dev
  */
 public static function exitWithFailedRequest($msg = '')
 {
     if ($msg) {
         Cli::writeError($msg);
     }
     self::exitWith(self::EXIT_CODE_VALID_REQUEST_FAILED);
 }
Пример #15
0
 public function test_spawn_speed()
 {
     $start = time();
     \Cli::spawn('sleep 2');
     $stop = time();
     $this->assertEquals($start, $stop);
 }
Пример #16
0
 /**
  * Detects and returns the current URI based on a number of different server
  * variables.
  *
  * @return  string
  */
 public static function uri()
 {
     if (static::$detected_uri !== null) {
         return static::$detected_uri;
     }
     if (\Fuel::$is_cli) {
         if ($uri = \Cli::option('uri') !== null) {
             static::$detected_uri = $uri;
         } else {
             static::$detected_uri = \Cli::option(1);
         }
         return static::$detected_uri;
     }
     // We want to use PATH_INFO if we can.
     if (!empty($_SERVER['PATH_INFO'])) {
         $uri = $_SERVER['PATH_INFO'];
     } elseif (!empty($_SERVER['ORIG_PATH_INFO']) and ($path = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['ORIG_PATH_INFO'])) != '') {
         $uri = $path;
     } else {
         // Fall back to parsing the REQUEST URI
         if (isset($_SERVER['REQUEST_URI'])) {
             $uri = $_SERVER['REQUEST_URI'];
         } else {
             throw new \FuelException('Unable to detect the URI.');
         }
         // Remove the base URL from the URI
         $base_url = parse_url(\Config::get('base_url'), PHP_URL_PATH);
         if ($uri != '' and strncmp($uri, $base_url, strlen($base_url)) === 0) {
             $uri = substr($uri, strlen($base_url));
         }
         // If we are using an index file (not mod_rewrite) then remove it
         $index_file = \Config::get('index_file');
         if ($index_file and strncmp($uri, $index_file, strlen($index_file)) === 0) {
             $uri = substr($uri, strlen($index_file));
         }
         // When index.php? is used and the config is set wrong, lets just
         // be nice and help them out.
         if ($index_file and strncmp($uri, '?/', 2) === 0) {
             $uri = substr($uri, 1);
         }
         // Lets split the URI up in case it contains a ?.  This would
         // indicate the server requires 'index.php?' and that mod_rewrite
         // is not being used.
         preg_match('#(.*?)\\?(.*)#i', $uri, $matches);
         // If there are matches then lets set set everything correctly
         if (!empty($matches)) {
             $uri = $matches[1];
             $_SERVER['QUERY_STRING'] = $matches[2];
             parse_str($matches[2], $_GET);
         }
     }
     // Strip the defined url suffix from the uri if needed
     if (strpos($uri, '.') !== false) {
         static::$detected_ext = preg_replace('#(.*)\\.#', '', $uri);
         $uri = substr($uri, 0, -(strlen(static::$detected_ext) + 1));
     }
     // Do some final clean up of the uri
     static::$detected_uri = \Security::clean_uri($uri, true);
     return static::$detected_uri;
 }
Пример #17
0
 public function bootstrap()
 {
     $this->constant();
     //加载服务配置项
     $servers = (require __DIR__ . '/service.php');
     $config = (require ROOT_PATH . '/system/config/service.php');
     $servers['providers'] = array_merge($config['providers'], $servers['providers']);
     $servers['facades'] = array_merge($config['facades'], $servers['facades']);
     $this->servers = $servers;
     //自动加载系统服务
     Loader::register([$this, 'autoload']);
     //绑定核心服务提供者
     $this->bindServiceProvider();
     //添加初始实例
     $this->instance('App', $this);
     //设置外观类APP属性
     ServiceFacade::setFacadeApplication($this);
     //启动服务
     $this->boot();
     //定义错误/异常处理
     Error::bootstrap();
     //命令行模式
     IS_CLI and die(Cli::bootstrap());
     //导入类库别名
     Loader::addMap(c('app.alias'));
     //自动加载文件
     Loader::autoloadFile();
     //开启会话
     Session::start();
     //执行全局中间件
     Middleware::globals();
     //解析路由
     Route::dispatch();
 }
Пример #18
0
	public static function run($task, $args)
	{
		// Just call and run() or did they have a specific method in mind?
		list($task, $method)=array_pad(explode(':', $task), 2, 'run');

		$task = ucfirst(strtolower($task));

		if ( ! $file = \Fuel::find_file('tasks', $task))
		{
			throw new \Exception('Well that didnt work...');
			return;
		}

		require $file;

		$task = '\\Fuel\\Tasks\\'.$task;

		$new_task = new $task;

		// The help option hs been called, so call help instead
		if (\Cli::option('help') && is_callable(array($new_task, 'help')))
		{
			$method = 'help';
		}

		if ($return = call_user_func_array(array($new_task, $method), $args))
		{
			\Cli::write($return);
		}
	}
Пример #19
0
 public final function execute()
 {
     $hasThreads = function_exists('pcntl_signal');
     if (!$hasThreads || Cli::getInstance()->isSimulation()) {
         flush();
         try {
             return $this->executeNoThread();
         } catch (Interrupt $e) {
             throw $e;
         } catch (Exception $e) {
             echo $e;
         }
         return;
     }
     pcntl_signal(SIGCHLD, SIG_IGN);
     $pid = pcntl_fork();
     if ($pid < 1) {
         $this->_run();
         posix_kill(posix_getpid(), 9);
         pcntl_waitpid(posix_getpid(), $temp = 0, WNOHANG);
         pcntl_wifexited($temp);
         exit;
         //Make sure we exit...
     } else {
         $this->pid = $pid;
     }
 }
Пример #20
0
 public static function detect()
 {
     if (static::$detected_uri !== null) {
         return static::$detected_uri;
     }
     if (\Fuel::$is_cli) {
         if ($uri = \Cli::option('uri') !== null) {
             static::$detected_uri = $uri;
         } else {
             static::$detected_uri = \Cli::option(1);
         }
         return static::$detected_uri;
     }
     // We want to use PATH_INFO if we can.
     if (!empty($_SERVER['PATH_INFO'])) {
         $uri = $_SERVER['PATH_INFO'];
     } elseif (!empty($_SERVER['ORIG_PATH_INFO']) and ($path = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['ORIG_PATH_INFO'])) != '') {
         $uri = $path;
     } else {
         // Fall back to parsing the REQUEST URI
         if (isset($_SERVER['REQUEST_URI'])) {
             // Some servers require 'index.php?' as the index page
             // if we are using mod_rewrite or the server does not require
             // the question mark, then parse the url.
             if (\Config::get('index_file') != 'index.php?') {
                 $uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
             } else {
                 $uri = $_SERVER['REQUEST_URI'];
             }
         } else {
             throw new \Fuel_Exception('Unable to detect the URI.');
         }
         // Remove the base URL from the URI
         $base_url = parse_url(\Config::get('base_url'), PHP_URL_PATH);
         if ($uri != '' and strncmp($uri, $base_url, strlen($base_url)) === 0) {
             $uri = substr($uri, strlen($base_url));
         }
         // If we are using an index file (not mod_rewrite) then remove it
         $index_file = \Config::get('index_file');
         if ($index_file and strncmp($uri, $index_file, strlen($index_file)) === 0) {
             $uri = substr($uri, strlen($index_file));
         }
         // Lets split the URI up in case it containes a ?.  This would
         // indecate the server requires 'index.php?' and that mod_rewrite
         // is not being used.
         preg_match('#(.*?)\\?(.*)#i', $uri, $matches);
         // If there are matches then lets set set everything correctly
         if (!empty($matches)) {
             $uri = $matches[1];
             $_SERVER['QUERY_STRING'] = $matches[2];
             parse_str($matches[2], $_GET);
         }
     }
     // Strip the defined url suffix from the uri if needed
     $ext = \Config::get('url_suffix');
     strrchr($uri, '.') === $ext and $uri = substr($uri, 0, -strlen($ext));
     // Do some final clean up of the uri
     static::$detected_uri = str_replace(array('//', '../'), '/', $uri);
     return static::$detected_uri;
 }
Пример #21
0
 public static function getInstance($argv = null)
 {
     if (self::$instance === null) {
         self::$instance = new Cli($argv);
     }
     return self::$instance;
 }
Пример #22
0
 /**
  * Puts together the POST body when uploading files
  *
  * @param array  $postData
  * @param array  $files An array of files like `[string $fileName => string|resource|array $file]`.
  *                      In case $file is an array it provides additional control on file name and contents type.
  *                      Available keys are `path`, `fileContents`, `fileName` and `contentType`. One of `path` or
  *                      `fileContents` is required.
  *                      If `path` is set then `fileName` and `contentType` are optional.
  *                      If `fileContents` is set then `fileName` and `contentType` are required.
  *
  *                      examples:
  *                      <ul>
  *                      <li>['file1' => ['path' => '/tmp/file.php']]</li>
  *                      <li>['file1' => ['path' => '/tmp/file.php'], 'file2' => ['path' => '/tmp/file2.png']]</li>
  *                      <li>['file1' => ['fileContents' => '<?php echo 1;', 'fileName' => 'o.png', 'contentType' => 'image/png']]</li>
  *                      </ul>
  * @param string $formBoundary
  *
  * @return string
  * @author Panagiotis Vagenas <*****@*****.**>
  * @since  0-dev
  */
 protected static function getUploadFormData($postData = [], $files = [], $formBoundary = '__FORM_BOUNDARY__')
 {
     $postData = (array) $postData;
     $formBoundary = preg_replace('/\\W/', '', $formBoundary);
     $payload = [];
     foreach ($postData as $paramName => $value) {
         $payload[] = '--' . $formBoundary;
         $payload[] = 'Content-Disposition: form-data; name="' . $paramName . '"';
         $payload[] = '';
         $payload[] = $value;
     }
     /** @var resource|string|array $file */
     foreach ($files as $paramName => $file) {
         $fileData = self::getFileData($file);
         if (isset($fileData['error'])) {
             Cli::writeError("Something went wrong with file {$paramName} (error: {$fileData['error']}), skipping...");
             continue;
         }
         $payload[] = '--' . $formBoundary;
         $payload[] = 'Content-Disposition: form-data; name="' . $paramName . '"; filename="' . $fileData['fileName'] . '"';
         $payload[] = "Content-Type: {$fileData['contentType']}";
         $payload[] = '';
         $payload[] = $fileData['fileContents'];
         $payload[] = '';
     }
     $payload[] = '--' . $formBoundary;
     $payload[] = '';
     return implode(CRLF, $payload);
 }
Пример #23
0
 public function install()
 {
     $bdd = Bdd::getInstance();
     $filename = DATA_DIR . "/data.json";
     Cli::pinfo("Import {$filename} in database");
     $data = json_decode(file_get_contents($filename));
     $bdd->import($data);
 }
Пример #24
0
 public function foursquare_venue($venue_id, $cycles = 25)
 {
     if ($this->spider->updateFoursquareVenue($venue_id, $cycles)) {
         \Cli::write('Scan finished.');
     } else {
         \Cli::error('No region found / Invalid region id');
     }
 }
Пример #25
0
 /**
  * Sync assets to CDN
  */
 public function sync()
 {
     \Cli::write("Syncing user files...");
     Storage::syncFileFields();
     \Cli::write("Syncing static assets...");
     Storage::syncAssets();
     \Cli::write("Done!", 'green');
 }
Пример #26
0
 /**
  * Listen to a queue
  *
  * @param mixed $queue
  */
 public function run($queue = 'default', $connector = null)
 {
     $worker = \Worker::forge($queue, $connector);
     // Register shutdown function to catch exit
     // \Event::register('shutdown', $this->shutdown);
     $interval = \Cli::option('interval', \Cli::option('i', 5));
     $worker->listen($interval);
 }
Пример #27
0
 /**
  *
  * @return string
  */
 public function set_reservable()
 {
     \Config::load("base");
     $taskName = __METHOD__;
     \Cli::write(\TaskUtil::decorate(\Config::get("system.code") . " {$taskName} START"));
     $model = new \Model_Task_Setreservable();
     $model->run();
     \Cli::write(\TaskUtil::decorate(\Config::get("system.code") . " {$taskName} END"));
 }
Пример #28
0
 /**
  * Install registries table
  *
  * @static
  * @access  protected
  * @return  void
  */
 public static function generate($table_name = null)
 {
     $table_name or $table_name = \Config::get('hybrid.tables.registry', 'options');
     $class_name = \Inflector::classify($table_name, true);
     if ('y' === \Cli::prompt("Would you like to install `registry.{$table_name}` table?", array('y', 'n'))) {
         Generate::migration(array('create_' . $table_name, 'name:string[255]', 'value:longtext'));
         Generate::$create_files = array();
     }
 }
Пример #29
0
 public static function down()
 {
     \Config::load('migrate', true);
     $version = \Config::get('migrate.version') - 1;
     if (\Migrate::version($version)) {
         static::_update_version($version);
         \Cli::write('Migrated to version: ' . $version . '.', 'green');
     }
 }
Пример #30
0
 /**
  *
  * @return string
  */
 public function run($type)
 {
     \Config::load("base");
     $taskName = "DATA MIGRATION";
     \Cli::write(\TaskUtil::decorate(\Config::get("system.code") . " {$taskName} START"));
     $model = new \Model_Task_Datamigration();
     $model->run($type);
     \Cli::write(\TaskUtil::decorate(\Config::get("system.code") . " {$taskName} END"));
 }