$include .= $path . PATH_SEPARATOR; } set_include_path($include . PATH_SEPARATOR . get_include_path()); } public static function loadDir($path) { Autoload::loadDir($path); } public static function run() { self::getInstance()->application->run(); } public function __destruct() { echo "\n\n"; } } } namespace { function desc($description) { global $tab_last_description; $tab_last_description = $description; } function task($tasks = array(), $args = array(), $block) { $tab = Tab\Tab::getInstance(); $tab->application->defineTask("Tab\\Task", $tasks, $args, $block); } \Tab\Tab::run(); }
<?php desc("lists all the tasks"); task("-T", null, function () { $application = \Tab\Tab::getInstance()->application; $tasks = $application->tasks; usort($tasks, function ($a, $b) { return strcmp($a->name, $b->name); }); echo "\n " . str_pad("Tasks", 40) . "Description\n"; foreach ($tasks as $task) { echo " " . str_pad($task->name, 40) . $task->description . "\n"; } }); desc("gives the version"); task("-v", null, function () { echo "tab-php: v1 alpha"; });