示例#1
0
 /**
  * Initialize commands
  *
  * @param  array                 $args    Arguments
  * @param  Projek\CI\Console\Cli $command
  * @return mixed
  */
 public function initialize($args, Cli $command)
 {
     // Set command description
     $command->set_description($this->description);
     // Every single command should have help, right?
     $command->add_arg('help', ['prefix' => 'h', 'longPrefix' => 'help', 'description' => Cli::lang('console_display_help'), 'noValue' => true]);
     // 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;
     }
 }