mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/9805] Add dry-run option.
PHPBB3-9805
This commit is contained in:
parent
57bd0c74e5
commit
8eee36dc0f
1 changed files with 19 additions and 3 deletions
|
@ -40,16 +40,19 @@ function show_usage()
|
|||
echo " -u github_username Overwrites the github username (optional)\n";
|
||||
echo " -r repository_name Overwrites the repository name (optional)\n";
|
||||
echo " -m your_github_username Sets up ssh:// instead of git:// for pushable repositories (optional)\n";
|
||||
echo " -d Outputs the commands instead of running them (optional)\n";
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Handle arguments
|
||||
$opts = getopt('s:u:r:m:');
|
||||
$opts = getopt('s:u:r:m:d');
|
||||
$scope = get_arg($opts, 's', '');
|
||||
$username = get_arg($opts, 'u', 'phpbb');
|
||||
$repository = get_arg($opts, 'r', 'phpbb3');
|
||||
$developer = get_arg($opts, 'm', '');
|
||||
$dry_run = !get_arg($opts, 'd', true);
|
||||
run(null, $dry_run);
|
||||
|
||||
// Get some basic data
|
||||
$network = get_network($username, $repository);
|
||||
|
@ -189,7 +192,20 @@ function get_arg($array, $index, $default)
|
|||
return isset($array[$index]) ? $array[$index] : $default;
|
||||
}
|
||||
|
||||
function run($cmd)
|
||||
function run($cmd, $dry = false)
|
||||
{
|
||||
passthru(escapeshellcmd($cmd));
|
||||
static $dry_run;
|
||||
|
||||
if (is_null($cmd))
|
||||
{
|
||||
$dry_run = $dry;
|
||||
}
|
||||
else if (!empty($dry_run))
|
||||
{
|
||||
echo "$cmd\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
passthru(escapeshellcmd($cmd));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue