shithub: rc

ref: 7c063c346a361bca2e57e26e04e8fb48a05c8c7e
dir: /bin/repoadd/

View raw version
#!/bin/rc -e
rfork ne
fn usage{
	echo usage: $0 '[-u user] REPO [DESC..]' >[1=2]
	exit usage
}

root=/sys/lib/extra
repodir=usr
user=()
while(~ $1 -?){
	switch($1){
	case -u
		user=$2
		shift 2
	case *
		usage
	}
}
if(~ $#* 0)
	usage
repo=(`{echo $1 | sed 's,.*/([^/]+)/([^/]+)/?$,\1 \2,'})
url=$1
shift
if(~ $#user 0)
	user=$repo(1)
repo=$repo(2)
dir=$root/$repodir/$user

git/clone $url $dir/$repo
echo $url^'	'^$user/^$repo^'	'^$dir/$repo^'	'^$"*