/
srfi
executable file
·84 lines (68 loc) · 1.83 KB
/
srfi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/perl -w
# Mit Jun 7 18:25:14 CEST 2006
(my $email='pflanze%gmx,ch')=~ tr/%,/@./;
use strict;
$0=~ /(.*?)([^\/]+)\z/s or die "?";
my ($mydir, $myname)=($1,$2);
sub usage {
print STDERR map{"$_\n"} @_ if @_;
print "$myname [options] [number]
Shows that srfi using the browser in the BROWSER env
var.
Options:
--top|--parent|--overview show the overview page instead
--index show index page instead
(Christian Jaeger <$email>)
";
exit @_ ? 1 : 0;
}
my @args;
my $DEBUG=0;
my $opt_overview;
my $opt_index;
for (my $i=0; $i<=$#ARGV; $i++) {
local $_=$ARGV[$i];
if (/^--?h(elp)?$/) {
usage
} elsif ($_ eq '--') {
push @args, @ARGV[$i+1..$#ARGV];
last;
} elsif (/^--?d(ebug)?$/) {
$DEBUG=1;
} elsif (/^--?(o(verview)?|t(op)?|p(arent)?)$/) {
$opt_overview=1;
} elsif (/^--?(i(ndex)?)$/) {
$opt_index=1;
# } elsif (/^--?X(?:XXX(?:=(.*))?)?$/) {
# if (defined $1) {
# $XXX=$1
# } else {
# $XXX=$ARGV[++$i] or usage "missing argument for '$_' option";
# }
} elsif (/^-./) {
usage("Unknown option '$_'\n");
} else {
push @args, $_
}
}
use Chj::Browser;
if ($opt_index) {
Browser_exec "http://srfi.schemers.org/"
} else {
usage "expecting one argument" unless @args==1;
my ($num)=@args;
$num=~ /^\d+\z/ or usage "not a number: '$num'";
# final:
# http://srfi.schemers.org/srfi-0/
# http://srfi.schemers.org/srfi-0/srfi-0.html
# draft:
# http://srfi.schemers.org/srfi-64/
# http://srfi.schemers.org/srfi-64/srfi-64.html
# withdrawn:
# http://srfi.schemers.org/srfi-73/
# http://srfi.schemers.org/srfi-73/srfi-73.html
Browser_exec
($opt_overview ?
"http://srfi.schemers.org/srfi-$num/"
: "http://srfi.schemers.org/srfi-$num/srfi-$num.html");
}