function run_help($task = null, $args = array(), $cliopts = array()) { /*if ( count( $args ) == 0 ) { // ... }*/ // work around a pake bug if (count($args) > 0) { $args[0] = pakeTask::get_full_task_name($args[0]); } $pake = pakeApp::get_instance(); $pake->run_help($task, $args); }
public function run($pakefile = null, $options = null, $load_pakefile = true) { if ($pakefile) { pakeApp::$PAKEFILES = array($pakefile); } $this->handle_options($options); if ($load_pakefile) { $this->load_pakefile(); } if ($this->show_tasks) { $this->display_tasks_and_comments(); } else { if ($this->show_prereqs) { $this->display_prerequisites(); } else { $args = $this->opt->get_arguments(); $task = array_shift($args); $options = array(); for ($i = 0, $max = count($args); $i < $max; $i++) { if (0 === strpos($args[$i], '--')) { if (false !== ($pos = strpos($args[$i], '='))) { $key = substr($args[$i], 2, $pos - 2); $value = substr($args[$i], $pos + 1); } else { $key = substr($args[$i], 2); $value = true; } if ('[]' == substr($key, -2)) { if (!isset($options[$key])) { $options[$key] = array(); } $options[$key][] = $value; } else { $options[$key] = $value; } unset($args[$i]); } } $args = array_values($args); $abbrev_options = $this->abbrev(array_keys(pakeTask::get_tasks())); $task = pakeTask::get_full_task_name($task); if (!$task) { $task = 'default'; } if (!array_key_exists($task, $abbrev_options)) { throw new pakeException(sprintf('Task "%s" is not defined.', $task)); } else { if (count($abbrev_options[$task]) > 1) { throw new pakeException(sprintf('Task "%s" is ambiguous (%s).', $task, implode(', ', $abbrev_options[$task]))); } else { return pakeTask::get($abbrev_options[$task][0])->invoke($args, $options); } } } } }
protected function initAndRunTaskInSubprocess($command) { if (function_exists('pcntl_fork')) { // UNIX $argv = explode(' ', $command); list($task_name, $args, $options) = self::parseTaskAndParameters($argv); $task_name = pakeTask::get_full_task_name($task_name); $pid = pcntl_fork(); if ($pid == -1) { die('could not fork'); } if ($pid) { // we are the parent pcntl_wait($status); $status = pcntl_wexitstatus($status); if ($status == self::QUIT_INTERACTIVE) { exit(0); } } else { try { $status = $this->initAndRunTask($task_name, $args, $options); if (true === $status) { exit(0); } exit($status); } catch (pakeException $e) { pakeException::render($e); exit(1); } } } else { // WINDOWS $php_exec = escapeshellarg((isset($_SERVER['_']) and substr($_SERVER['_'], -4) != 'pake') ? $_SERVER['_'] : 'php'); $force_tty = ''; if (defined('PAKE_FORCE_TTY') or DIRECTORY_SEPARATOR != '\\' and function_exists('posix_isatty') and @posix_isatty(STDOUT)) { $force_tty = ' --force-tty'; } $pake_php = escapeshellarg($_SERVER['SCRIPT_NAME']); $import_flag = ' --import=interactive'; system($php_exec . ' ' . $pake_php . $force_tty . $import_flag . ' ' . $command, $status); if ($status == self::QUIT_INTERACTIVE) { exit(0); } } }
protected function runDefaultTask() { return $this->initAndRunTask(pakeTask::get_full_task_name('default'), array(), array()); }
public function run($pakefile = null, $options = null, $load_pakefile = true) { if ($pakefile) { pakeApp::$PAKEFILES = array($pakefile); } $this->handle_options($options); if ($load_pakefile) { $this->load_pakefile(); } if ($this->show_tasks) { $this->display_tasks_and_comments(); } else { if ($this->show_prereqs) { $this->display_prerequisites(); } else { $args = $this->opt->get_arguments(); $task = array_shift($args); $abbrev_options = $this->abbrev(array_keys(pakeTask::get_tasks())); $task = pakeTask::get_full_task_name($task); if (!$task) { $task = 'default'; } if (!array_key_exists($task, $abbrev_options)) { throw new pakeException(sprintf('Task "%s" is not defined.', $task)); } else { if (count($abbrev_options[$task]) > 1) { throw new pakeException(sprintf('Task "%s" is ambiguous (%s).', $task, implode(', ', $abbrev_options[$task]))); } else { return pakeTask::get($abbrev_options[$task][0])->invoke($args); } } } } }