forked from markvanderloo/stringdist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drat.sh
executable file
·35 lines (25 loc) · 817 Bytes
/
drat.sh
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
#!/usr/bin/Rscript
suppressPackageStartupMessages({
if (!require("drat")) stop("drat not installed")
if (!require("docopt")) stop("docopt not installed")
})
"Usage: drat.sh [commit] [--pkg FILE] [--dratrepo FOLDER]
commit commit after insert?
--pkg FILE The tarball to insert in the drat repo (by default the tarball in ./output)
--dratrepo FOLDER path to root of drat repo [default: ../drat]
" -> doc
opt <- docopt(doc)
stopifnot(file.exists(opt$dratrepo))
pkg <- opt$pkg
if ( is.null(pkg) ){
pkg <- dir("output/",pattern = ".*tar\\.gz",full.names = TRUE)
}
if (!file.exists(pkg)){
stop(sprintf("%s not found",pkg))
}
drat::insertPackage(pkg, repodir=opt$dratrepo, commit=opt$commit)
cat(sprintf("Inserted %s into %s %s\n"
, pkg
, opt$dratrepo
, if(opt$commit) "and committed" else ""
))