/** * Display the console and execute callbacks associated * to the command */ public static function onAtomikStart() { $paths = (array) self::$config['scripts_dir']; foreach (Atomik::getLoadedPlugins(true) as $plugin => $path) { $paths[] = "{$path}/scripts"; } foreach (array_filter(array_map('realpath', $paths)) as $path) { self::$console->addCommandsFromDir($path, '', true); } self::$console->run(); exit; }
/** * init bim applications * @throws \Exception */ public static function init() { $conf = new Config(__DIR__ . "/config/commands.json"); $console = new Console($conf->get("commands")); # run commands $console->run(); }
} /** * Says hi to someone * * @arg name The name of the person to say hello to */ public function executeHi(array $args, array $options = array()) { $this->writeln(sprintf('hi %s!', $args[0])); } } /** * Displays a progress bar * * @opt total Number of iterations * @opt usleep Waiting time in microsecond between each iteration */ function progress($args, $options, $console) { $total = isset($options['total']) ? $options['total'] : 100; $usleep = isset($options['usleep']) ? $options['usleep'] : 10000; $progress = new ProgressBar($console, $total); for ($i = 0; $i < $total; $i++) { $progress->incr(); usleep($usleep); } $progress->stop(); } $console = new Console(array('hello' => 'HelloWorldCommand', 'SayHelloCommand', 'SayCommand', 'progress')); $console->run();