$checklist = new ConsoleKit\Widgets\Checklist($console);
$checklist->run(array(
'Creating directory structure' => function() {
code
return $success; // bool
},
'Downloading scripts' => function() {
code
return $success; // bool
}
));
Will print:
Creating directory structure OK
Downloading scripts OK
/** * Run a list of updates * * @param array $files */ protected function runUpdates(array $files) { $steps = array(); $config = $this->dbvc()->config; $checklist = new Checklist($this->getConsole()->getTextWriter()); $db = $this->dbvc()->db(); $this->writeln("Running updates for database '{$config->db->dbname}':", Colors::YELLOW); foreach ($files as $update => $file) { $file = $config->datadir . DIRECTORY_SEPARATOR . 'updates' . DIRECTORY_SEPARATOR . $file; $message = " {$update} "; if ($this->force) { $steps[$message] = function () use($db, $update, $file) { try { $db->run($file); } catch (\Exception $e) { return false; } $db->markUpdate($update); return true; }; } else { $steps[$message] = function () use($db, $update, $file) { $db->run($file); $db->markUpdate($update); return true; }; } } $checklist->run($steps); }
/** * Generate command. * index.php generate action_name [action_name [action_name [...]]] * * @param array $arguments */ public static function generate($args, $opts, $console) { $checklist = new ConsoleKit\Widgets\Checklist($console); foreach ($args as $action) { $console->writeln("Generating '{$action}'"); $filename = ltrim($action, '/') . '.php'; $actionsDir = (array) Atomik::get('atomik.dirs.actions'); $actionsDir = array_shift($actionsDir); $checklist->step("Creating action file in {$actionsDir}", function () use($actionsDir, $filename) { return ConsoleKit\FileSystem::touch(ConsoleKit\FileSystem::join($actionsDir, $filename), "<?php\n\n// Logic goes here\n"); }); $viewsDir = (array) Atomik::get('atomik.dirs.views'); $viewsDir = array_shift($viewsDir); $checklist->step("Creating view file in {$viewsDir}", function () use($viewsDir, $filename) { return ConsoleKit\FileSystem::touch(ConsoleKit\FileSystem::join($viewsDir, $filename)); }); Atomik::fireEvent('Console::Generate', array($action)); } }