aboutsummaryrefslogtreecommitdiffstats
path: root/git-tools/setup_github_network.php
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2011-01-16 17:02:19 +0100
committerAndreas Fischer <bantu@phpbb.com>2011-02-03 11:12:41 +0100
commit57bd0c74e50e2171653d45d9723f2417411c71f4 (patch)
tree4a11dc0b696aab56c918617686308a472673e76c /git-tools/setup_github_network.php
parentbe3a0b269a7ddff2e5f0f2ae364cf2e50c780980 (diff)
downloadforums-57bd0c74e50e2171653d45d9723f2417411c71f4.tar
forums-57bd0c74e50e2171653d45d9723f2417411c71f4.tar.gz
forums-57bd0c74e50e2171653d45d9723f2417411c71f4.tar.bz2
forums-57bd0c74e50e2171653d45d9723f2417411c71f4.tar.xz
forums-57bd0c74e50e2171653d45d9723f2417411c71f4.zip
[ticket/9805] Use getopt(), add a few options, extend show_usage().
PHPBB3-9805
Diffstat (limited to 'git-tools/setup_github_network.php')
-rw-r--r--git-tools/setup_github_network.php52
1 files changed, 34 insertions, 18 deletions
diff --git a/git-tools/setup_github_network.php b/git-tools/setup_github_network.php
index bc8e70cfbd..66d7db87da 100644
--- a/git-tools/setup_github_network.php
+++ b/git-tools/setup_github_network.php
@@ -9,7 +9,7 @@
if ($argc < 2)
{
- show_usage($argv);
+ show_usage();
}
if (file_exists('.git'))
@@ -18,13 +18,38 @@ if (file_exists('.git'))
exit(1);
}
-// Handle arguments
-$scope = get_arg($argv, 1, '');
-$developer = get_arg($argv, 2, '');
+function show_usage()
+{
+ $filename = basename(__FILE__);
+
+ echo "$filename adds repositories of a github network as remotes to a local git repository.\n";
+ echo "\n";
+
+ echo "Usage: php $filename -s collaborators|organisation|contributors|network [OPTIONS]\n";
+ echo "\n";
+
+ echo "Scopes:\n";
+ echo " collaborators Repositories of people who have push access to the specified repository\n";
+ echo " contributors Repositories of people who have contributed to the specified repository\n";
+ echo " organisation Repositories of members of the organisation at github\n";
+ echo " network All repositories of the whole github network\n";
+ echo "\n";
+
+ echo "Options:\n";
+ echo " -s scope See description above (mandatory)\n";
+ 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";
+
+ exit(1);
+}
-// Github setup
-$username = 'phpbb';
-$repository = 'phpbb3';
+// Handle arguments
+$opts = getopt('s:u:r:m:');
+$scope = get_arg($opts, 's', '');
+$username = get_arg($opts, 'u', 'phpbb');
+$repository = get_arg($opts, 'r', 'phpbb3');
+$developer = get_arg($opts, 'm', '');
// Get some basic data
$network = get_network($username, $repository);
@@ -159,18 +184,9 @@ function get_network($username, $repository)
return $usernames;
}
-function show_usage($argv)
-{
- printf(
- "usage: php %s collaborators|organisation|contributors|network [your_github_username]\n",
- basename($argv[0])
- );
- exit(1);
-}
-
-function get_arg($argv, $index, $default)
+function get_arg($array, $index, $default)
{
- return isset($argv[$index]) ? $argv[$index] : $default;
+ return isset($array[$index]) ? $array[$index] : $default;
}
function run($cmd)