Created
September 23, 2014 14:20
-
-
Save spolischook/05d81a4fa69623f75277 to your computer and use it in GitHub Desktop.
Base script for CLI scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function show_run($text, $command, $canFail = false) | |
| { | |
| echo "\n* $text\n$command\n"; | |
| passthru($command, $return); | |
| if (0 !== $return && !$canFail) { | |
| echo "\n/!\\ The command returned $return\n"; | |
| exit(1); | |
| } | |
| } | |
| function show_action($action) | |
| { | |
| echo file_get_contents(__DIR__.'/banner'); | |
| printf("\n %s\n| %s |\n %s\n", str_repeat('-', strlen($action)+2), $action, str_repeat('-', strlen($action)+2)); | |
| } | |
| function read_arg(array $argv, $index, $default = null) | |
| { | |
| return isset($argv[$index+1]) ? $argv[$index+1] : $default; | |
| } | |
| function build_bootstrap() | |
| { | |
| show_run('Building bootstrap', 'vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php app'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment