function process_argv(&$argv) { return \taskman_process_argv($argv); }
<?php $limb_dir = dirname(__FILE__); require_once $limb_dir . '/taskman/taskman.inc.php'; taskman_process_argv($argv); lmb_cli_init_limb($limb_dir); taskman_propsetor('LIMB_DIR', $limb_dir . '/../'); taskman_propsetor('TASKS_MASKS', 'limb/*/cli/*.tasks.php' . PATH_SEPARATOR . 'src/*/cli/*.tasks.php'); if (null === taskman_propor('PROJECT_DIR', null)) { taskman_propsetor('PROJECT_DIR', lmb_get_project_dir()); } lmb_cli_init_project(taskman_prop('PROJECT_DIR')); lmb_cli_init_tasks(); taskman_run(); function lmb_get_project_dir() { if (!($project_dir = get_cfg_var('limb.project_dir'))) { $project_dir = lmb_cli_ask_for_option('Project directory', lmb_cli_find_project_dir(getcwd())); } else { echo "Project directory loaded from PHP config: {$project_dir}\n"; } return $project_dir; } function lmb_cli_find_project_dir($current_dir) { if (file_exists($current_dir . '/setup.php')) { ob_start(); register_shutdown_function('lmb_cli_check_limb_instance'); lmb_require($current_dir . '/setup.php'); ob_end_clean(); lmb_cli_check_limb_instance($disable = true);
function taskman_run($argv = null, $help_func = 'task_help') { if (is_null($argv)) { $argv = $GLOBALS['argv']; } taskman_process_argv($argv); $GLOBALS['TASKMAN_SCRIPT'] = array_shift($argv); taskman_collecttasks(); $always_task = null; $default_task = null; foreach (taskman_gettasks() as $task_obj) { if ($task_obj->hasProp('always')) { $always_task = $task_obj; } if ($task_obj->hasProp('default')) { $default_task = $task_obj; } } if (sizeof($argv) > 0) { $task_str = array_shift($argv); $tasks = taskman_parse_taskstr($task_str); if ($always_task) { $always_task->run($argv); } taskman_runtasks($tasks, $argv); } else { if ($default_task) { if ($always_task) { $always_task->run($argv); } $default_task->run($argv); } else { $help_func(); exit; } } taskman_sysmsg("************************ All done ************************\n"); }
function taskman_run($argv = null, $help_func = 'taskman_default_usage') { if (is_null($argv)) { $argv = $GLOBALS['argv']; } $bench = microtime(true); taskman_configset('help_func', $help_func); taskman_process_argv($argv); $GLOBALS['TASKMAN_SCRIPT'] = array_shift($argv); taskman_collecttasks(); $always_task = null; $default_task = null; foreach (taskman_gettasks() as $task_obj) { if ($task_obj->hasProp('always')) { $always_task = $task_obj; } if ($task_obj->hasProp('default')) { $default_task = $task_obj; } } if (sizeof($argv) > 0) { $task_str = array_shift($argv); $tasks = taskman_parse_taskstr($task_str); if ($always_task) { $always_task->run($argv); } taskman_runtasks($tasks, $argv); } else { if ($default_task) { if ($always_task) { $always_task->run($argv); } $default_task->run($argv); } else { taskman_runtask('help'); exit; } } taskman_sysmsg("************************ All done (" . round(microtime(true) - $bench, 2) . " sec.)************************\n"); }