Skip to content

Instantly share code, notes, and snippets.

@spolischook
Created September 23, 2014 14:20
Show Gist options
  • Select an option

  • Save spolischook/05d81a4fa69623f75277 to your computer and use it in GitHub Desktop.

Select an option

Save spolischook/05d81a4fa69623f75277 to your computer and use it in GitHub Desktop.
Base script for CLI scripts
<?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