Message-ID: <22957.26924.772705.218777@bud.eddelbuettel.com>
Date: 2017-09-04T14:54:36Z
From: Dirk Eddelbuettel
Subject: [R-pkg-devel] installing packages from github
In-Reply-To: <DB5PR0401MB17816D3952BE3F5899DEF271D5910@DB5PR0401MB1781.eurprd04.prod.outlook.com>
On 4 September 2017 at 14:22, Berry Boessenkool wrote:
| - do I miss something obvious?
The part where devtools has been undergoing a renovation for some time now
splitting functionality into many small packages?
I have my own views on repos with clearly marked and explicitly prepared
releases versus 'installing random commit snapshots from GH' -- but sometimes
you need the latter and I tend to use the helper below at the shell prompt.
It switches to using remotes quite some time ago.
Dirk
#!/usr/bin/env r
#
# A simple example to install one or more packages from GitHub
#
# Copyright (C) 2014 - 2016 Carl Boettiger and Dirk Eddelbuettel
#
# Released under GPL (>= 2)
## load docopt and remotes (or devtools) from CRAN
suppressMessages(library(docopt)) # we need docopt (>= 0.3) as on CRAN
suppressMessages(library(remotes)) # can use devtools as a fallback
## configuration for docopt
doc <- "Usage: installGithub.r [-h] [-x] [-d DEPS] [-u UPDATE] [REPOS...]
-d --deps DEPS install suggested dependencies as well? [default: NA]
-u --update UPDATE update dependencies? [default: TRUE]
-h --help show this help text
-x --usage show help and short example usage"
opt <- docopt(doc) # docopt parsing
if (opt$usage) {
cat(doc, "\n\n")
cat("where REPOS... is one or more GitHub repositories.
Examples:
installGithub.r RcppCore/RcppEigen
installGithub.r is part of littler which brings 'r' to the command-line.
See http://dirk.eddelbuettel.com/code/littler.html for more information.\n")
q("no")
}
## docopt parsing
opt <- docopt(doc)
if (opt$deps == "TRUE" || opt$deps == "FALSE") {
opt$deps <- as.logical(opt$deps)
} else if (opt$deps == "NA") {
opt$deps <- NA
}
opt$update <- as.logical(opt$update)
invisible(sapply(opt$REPOS, function(r) install_github(r, dependencies = opt$deps, upgrade = opt$update)))
--
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org