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); } }
/** * 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); } }