-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgithub
More file actions
executable file
·83 lines (78 loc) · 1.41 KB
/
github
File metadata and controls
executable file
·83 lines (78 loc) · 1.41 KB
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
#!/bin/rc
# Call this command:
# hget https://github.com/$1/blob/$branch/$2|sed -ne '/<article/,/<\/article/p'|htmlfmt
# where $1 is the user/repository (mandatory), $branch might be given as --branch or -b option
# TODO: add a cache directory argument, to locally store/update such files (options --cache, -c)
args=$*
rest=$*
pos = ()
repo = ''
branch = 'master'
mode = 'raw'
modedefault = 1
file = 'README.md'
while ( ! ~ $#args 0 ) {
k = $1
if ( ~$k '--' ) {
shift
rest = $*
shift $#rest
}
if not if ( ~$k '--'* ) {
# echo 'handle long option '$k
if ( ~$k '--branch' ) {
shift
branch = $1
}
if not if ( ~$k '--blob' ) {
mode = 'blob'
modedefault = 0
}
if not if ( ~$k '--raw' ) {
mode = 'raw'
modedefault = 0
}
shift
}
if not if ( ~$k '-'* ) {
# echo 'handle option '$k
if ( ~$k '-b' ) {
shift
branch = $1
}
shift
}
if not {
# echo 'pos = '$#pos
if ( ~ $#pos 0 ) {
repo = $k
}
if not if ( ~ $#pos 1 ) {
file = $k
}
pos=($pos '#')
shift
}
args = $*
}
if ( ~ $repo '' ) {
echo 'no repository given' >[1=2]
exit 'no repository'
}
if ( ~ $file *'.md' ) {
if ( ~ $modedefault 1 ) {
mode = 'blob'
}
}
ramfs -p
fullurl = 'https://github.com/'$repo'/'$mode'/'$branch'/'$file
# echo $fullurl
ofile = /tmp/github.$pid
hget -o $ofile $fullurl
if ( ~ $mode 'blob' ) {
cat $ofile |sed -ne '/<article/,/<\/article/p'|htmlfmt
}
if not {
cat $ofile
}
rm $ofile