Пример #1
0
 public function execute(array $options)
 {
     if ($options['force'] === NULL or 'yes' === Minion_CLI::read('This will destroy all data in the current database. Are you sure? [yes/NO]')) {
         Minion_CLI::write('Dropping Tables', 'green');
         $migrations = new Migrations(array('log' => 'Minion_CLI::write'));
         $migrations->clear_all();
         Minion_Task::factory('db:migrate')->execute($options);
     } else {
         Minion_CLI::write('Nothing done', 'brown');
     }
 }
Пример #2
0
 public function execute(array $options)
 {
     $db = $this->db_params($options['database']);
     $file = $options['file'] ? $options['file'] : Kohana::$config->load("migrations.path") . DIRECTORY_SEPARATOR . 'schema.sql';
     if ($options['force'] === NULL or 'yes' === Minion_CLI::read("This will destroy database " . $db['database'] . " Are you sure? [yes/NO]")) {
         $command = strtr("mysql -u:username -p:password :database < :file ", array(':username' => $db['username'], ':password' => $db['password'], ':database' => $db['database'], ':file' => $file));
         Minion_CLI::write('Loading data from ' . Debug::path($file) . ' to ' . $db['database'], 'green');
         system($command);
     } else {
         Minion_CLI::write('Nothing done', 'brown');
     }
 }
Пример #3
0
 protected function _execute(array $params)
 {
     if ($params['db_driver'] === NULL) {
         $params['db_driver'] = Minion_CLI::read(__('Please enter database driver (:types)', array(':types' => implode(', ', array_keys($this->_installer->database_drivers())))));
     }
     if ($params['locale'] === NULL) {
         $params['locale'] = Minion_CLI::read(__('Please enter locale (:types)', array(':types' => implode(', ', array_keys(I18n::available_langs())))));
     }
     if ($params['db_name'] === NULL) {
         $params['db_name'] = Minion_CLI::read(__('Please enter database name'));
     }
     if ($params['timezone'] === NULL) {
         $answer = Minion_CLI::read(__('Select current timezone automaticly (:current)', array(':current' => date_default_timezone_get())), array('y', 'n'));
         if ($answer == 'y') {
             $params['timezone'] = date_default_timezone_get();
         } else {
             $params['timezone'] = Minion_CLI::read(__('Please enter current timezone (:site)', array(':site' => 'http://www.php.net/manual/en/timezones.php')), DateTimeZone::listIdentifiers());
         }
     }
     if ($params['cache_type'] === NULL) {
         $params['cache_type'] = Minion_CLI::read(__('Please enter cache type (:types)', array(':types' => implode(', ', array_keys($this->_installer->cache_types())))));
     }
     if ($params['session_type'] === NULL) {
         $session_types = Kohana::$config->load('installer')->get('session_types', array());
         $params['session_type'] = Minion_CLI::read(__('Please enter session type (:types)', array(':types' => implode(', ', array_keys($this->_installer->session_types())))));
     }
     if ($params['password'] !== NULL) {
         unset($params['password_generate']);
         $params['password_field'] = $params['password_confirm'] = $params['password'];
     }
     try {
         $this->_installer->install($params);
         Observer::notify('after_install', $params);
         Cache::clear_file();
         Minion_CLI::write('==============================================');
         Minion_CLI::write(__('KodiCMS installed successfully'));
         Minion_CLI::write('==============================================');
         $install_data = Session::instance()->get_once('install_data');
         Minion_CLI::write(__('Login: :login', array(':login' => Arr::get($install_data, 'username'))));
         Minion_CLI::write(__('Password: :password', array(':password' => Arr::get($install_data, 'password_field'))));
     } catch (Exception $e) {
         Minion_CLI::write(__(':text | :file [:line]', array(':text' => $e->getMessage(), ':file' => $e->getFile(), ':line' => $e->getLine())));
     }
 }
Пример #4
0
 protected function _execute(array $params)
 {
     if ($params['type'] === NULL) {
         $params['type'] = Minion_CLI::read(__('Please enter cache type foe clear (:types)', array(':types' => implode(', ', array('all', 'file', 'routes', 'profiler', CACHE_TYPE)))));
     }
     switch ($params['type']) {
         case 'file':
             Cache::clear_file();
             break;
         case 'routes':
             Cache::clear_routes();
             break;
         case 'profiler':
             Cache::clear_profiler();
             break;
         case CACHE_TYPE:
             Cache::instance()->delete_all();
             break;
         default:
             Cache::clear_all();
             break;
     }
     Minion_CLI::write('============ Cache ' . $params['type'] . ' cleared ==========');
 }
Пример #5
0
 /**
  * Waits a certain number of seconds, optionally showing a wait message and
  * waiting for a key press.
  *
  * @author     Fuel Development Team
  * @license    MIT License
  * @copyright  2010 - 2011 Fuel Development Team
  * @link       http://fuelphp.com
  * @param int $seconds number of seconds
  * @param bool $countdown show a countdown or not
  */
 public static function wait($seconds = 0, $countdown = false)
 {
     if ($countdown === true) {
         $time = $seconds;
         while ($time > 0) {
             fwrite(STDOUT, $time . '... ');
             sleep(1);
             $time--;
         }
         Minion_CLI::write();
     } else {
         if ($seconds > 0) {
             sleep($seconds);
         } else {
             Minion_CLI::write(Minion_CLI::$wait_msg);
             Minion_CLI::read();
         }
     }
 }
Пример #6
0
 /**
  * Reads input from the user. This can have either 1 or 2 arguments.
  *
  * Usage:
  *
  * // Waits for any key press
  * Minion_CLI::read();
  *
  * // Takes any input
  * $color = Minion_CLI::read('What is your favorite color?');
  *
  * // Will only accept the options in the array
  * $ready = Minion_CLI::read('Are you ready?', array('y','n'));
  *
  * @param  string $text    text to show user before waiting for input
  * @param  array  $options array of options the user is shown
  *
  * @return string  the user input
  */
 public static function read($text = '', array $options = null)
 {
     // If a question has been asked with the read
     $options_output = '';
     if (!empty($options)) {
         $options_output = ' [ ' . implode(', ', $options) . ' ]';
     }
     fwrite(STDOUT, $text . $options_output . ': ');
     // Read the input from keyboard.
     $input = trim(fgets(STDIN));
     // If options are provided and the choice is not in the array, tell them to try again
     if (!empty($options) && !in_array($input, $options)) {
         Minion_CLI::write('This is not a valid option. Please try again.');
         $input = Minion_CLI::read($text, $options);
     }
     // Read the input
     return $input;
 }