public function testBash() { $scripts = ['travis_ci_script_1' => function ($input, $output) { # I must be able to call a CLI or any classes here CLI::process('echo "Testing CLI::handleCallback()"'); $output->writeln("<comment>testing writeln with comment style</comment>"); $output->writeln("<error>testing writeln with error style</error>"); # also when returning an array or string # it should be able to handle this scripts return ['echo "Script 1: returning array in callback"']; }, 'travis_ci_script_2' => 'echo "Script 2: using CLI::process(<string>)"', 'travis_ci_script_3' => ['echo "Script 3: using CLI::bash(<array>)"'], 'travis_ci_script_4' => CLI::ssh('*****@*****.**', ['ls'], $execute = false), 'travis_ci_script_5' => function ($input, $output) { return 'echo "Script 5: returning string in callback"'; }]; # a callback, returning array CLI::handleCallback($scripts['travis_ci_script_1']); # a string CLI::process($scripts['travis_ci_script_2']); # an array CLI::bash($scripts['travis_ci_script_3']); # a generated ssh script // CLI::process($scripts['travis_ci_script_4']); # a callback, returning string CLI::handleCallback($scripts['travis_ci_script_5']); # this must automatically be executed, the third # parameter is automatically assigned as true // CLI::ssh('*****@*****.**', ['ls']); }
/** * {@inheritdoc} */ public function slash() { $script = $this->input->getArgument('script'); $lists = config()->script->toArray(); if (isset($lists[$script]) === false) { $this->error("\nWe can't find `" . $script . '` in the lists of script.' . "\n"); return; } foreach ($lists[$script] as $selected) { if (is_callable($selected)) { call_user_func($selected); continue; } if (!is_array($selected)) { CLI::process($selected); continue; } CLI::process(isset($selected['script']) ? $selected['script'] : null, isset($selected['prefix']) ? $selected['prefix'] : null, isset($selected['suffix']) ? $selected['suffix'] : null); } }
/** * {@inheritdoc} */ public function slash() { $script = $this->input->getArgument('script'); $lists = config()->script->toArray(); if (isset($lists[$script]) === false) { $this->error("\nWe can't find `" . $script . '` in the lists of script.' . "\n"); return; } foreach ($lists[$script] as $selected) { if (is_callable($selected)) { CLI::handleCallback($selected); continue; } if (is_array($selected)) { CLI::bash($selected); continue; } CLI::process($selected); } }
/** * {@inheritdoc} */ public function slash() { CLI::bash(['php brood clear:cache', 'php brood clear:compiled', 'php brood clear:logs', 'php brood clear:session', 'php brood clear:views']); }
/** * Call the composer's dumpautoload. * * @return void */ public function callDumpAutoload() { CLI::bash(['composer dumpautoload']); }
<?php use Clarity\Console\CLI; return ['pull' => ['cd ' . config('path.root'), 'git pull origin master', 'php brood clear:cache', 'php brood clear:logs', 'php brood clear:session', 'php brood clear:views', 'php brood db:migrate', 'composer update', 'composer dumpautoload'], 'deploy' => [CLI::ssh('*****@*****.**', function () { return ['cd /var/www', 'ls']; }, $execute = false)]]; # end of return
/** * This calls the 'composer dumpautoload --optimize'. * * @return void */ protected function callComposerOptimizer() { CLI::process('composer dumpautoload --optimize'); $compiled_file = config('path.root') . '/storage/slayer/compiled.php'; if (file_exists($compiled_file)) { $this->info('Removing previous compiled file...'); unlink($compiled_file); } }