3 #=======================================================================
5 # File ID: 3a9abebc-691e-11e0-9c71-8be79eda2807
9 # ©opyleft 2011– Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later, see end of
11 # file for legal stuff.
12 #=======================================================================
33 $progname =~ s/^.*\/(.*?)$/$1/;
34 our $VERSION = '0.00';
36 Getopt
::Long
::Configure
('bundling');
39 'create|c' => \
$Opt{'create'},
40 'debug' => \
$Opt{'debug'},
41 'help|h' => \
$Opt{'help'},
42 'verbose|v+' => \
$Opt{'verbose'},
43 'version' => \
$Opt{'version'},
45 ) || die("$progname: Option error. Use -h for help.\n");
47 $Opt{'debug'} && ($Debug = 1);
48 $Opt{'help'} && usage
(0);
49 if ($Opt{'version'}) {
57 $json = `curl -s http://github.com/api/v2/json/repos/show/$ARGV[0]/network`;
68 my ($url, $owner) = ($1, $2);
69 $url =~ s/^https:/git:/;
71 my $cmdstr = sprintf("git remote add github/%s %s", $owner, $url);
74 && print("Error creating remote github/$owner\n")
75 || print("Created remote github/$owner\n");
82 # Print program version {{{
83 print("$progname v$VERSION\n");
89 # Send the help message to stdout {{{
92 if ($Opt{'verbose'}) {
98 Usage: $progname [options] [user/repository]
100 If user/repository is specified, get info from GitHub, otherwise read
101 JSON from stdin. Needs curl(1).
106 Create remotes in current repository instead of merely printing
111 Increase level of verbosity. Can be repeated.
113 Print version information.
115 Print debugging messages.
123 # Print a status message to stderr based on verbosity level {{{
124 my ($verbose_level, $Txt) = @_;
126 if ($Opt{'verbose'} >= $verbose_level) {
127 print(STDERR
"$progname: $Txt\n");
134 # Print a debugging message {{{
136 my @call_info = caller;
137 chomp(my $Txt = shift);
138 my $File = $call_info[1];
140 $File =~ s
#^.*/(.*?)$#$1#;
141 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
148 # Plain Old Documentation (POD) {{{
158 [options] [file [files [...]]]
168 =item B<-h>, B<--help>
170 Print a brief help summary.
172 =item B<-v>, B<--verbose>
174 Increase level of verbosity. Can be repeated.
178 Print version information.
182 Print debugging messages.
192 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
196 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
197 This is free software; see the file F<COPYING> for legalese stuff.
201 This program is free software: you can redistribute it and/or modify it
202 under the terms of the GNU General Public License as published by the
203 Free Software Foundation, either version 2 of the License, or (at your
204 option) any later version.
206 This program is distributed in the hope that it will be useful, but
207 WITHOUT ANY WARRANTY; without even the implied warranty of
208 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
209 See the GNU General Public License for more details.
211 You should have received a copy of the GNU General Public License along
213 If not, see L<http://www.gnu.org/licenses/>.
221 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :