Example #1
0
 private function render_cli_error($heading, array $messages, $traces = [])
 {
     $cli = new Console();
     $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++;
         }
     }
 }
Example #2
0
 /**
  * Initialize commands
  *
  * @param  array                 $args    Arguments
  * @param  Bootigniter\Console $command
  * @return mixed
  */
 public function initialize($args, Console $command)
 {
     // Set command description
     $command->set_description($this->description);
     // Every single command should have help, right?
     $command->add_global_commands($command);
     // Register command arguments
     $this->register($command);
     try {
         // Parse the arguments
         $command->parse_arg($args);
         // If ask for help
         if ($command->get_arg('help') !== false) {
             return $command->usage([], $this->name);
         }
         // Execute actual arguments
         return $this->execute($command);
     } catch (\Exception $e) {
         $executed = false;
         return EXIT_USER_INPUT;
     }
 }
Example #3
0
 /**
  * {inheritdoc}
  */
 protected function outputArguments($arguments, $type)
 {
     if (count($arguments) == 0) {
         return;
     }
     $this->climate->br()->out(sprintf('<yellow>%s</yellow>:', Console::lang('console_argument_' . $type)));
     $len = [];
     foreach ($arguments as $argument) {
         $len[] = strlen($this->argument($argument));
     }
     foreach ($arguments as $argument) {
         $arg = $this->argument($argument);
         $spc = max($len) + 2 - strlen($arg);
         $str = '<green>' . $arg . '</green>' . str_repeat(' ', $spc);
         if ($argument->description()) {
             $str .= $argument->description();
         }
         $this->climate->tab()->out($str);
     }
 }
Example #4
0
 /**
  * Register default global commands
  *
  * @param Console $console
  */
 public function add_global_commands(Console $console)
 {
     $console->add_arg('help', ['prefix' => 'h', 'longPrefix' => 'help', 'description' => static::lang('console_display_help'), 'noValue' => true]);
 }
Example #5
0
 /**
  * Print the latest one
  *
  * @param  int                    $current Current version
  * @param  \Bootigniter\Console $command
  * @return \Bootigniter\Console
  */
 private function print_latest($current, $command)
 {
     return $command->out(sprintf(Console::lang('console_migration_label_latest'), '<green>' . $current . '</green>'));
 }
Example #6
0
 /**
  * Setup for NginX
  *
  * @param  Bootigniter\Console $command CLI instance
  * @return Bootigniter\Console
  */
 protected function setup_nginx(Console $command)
 {
     return $command->out(Console::lang('console_install_nginx_ready'));
 }