Skip to content

Commit 5fafe03

Browse files
authored
Support --quiet | --verbose in install2.r per #124 discussion (#126)
1 parent f3dee75 commit 5fafe03

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2025-07-09 Dirk Eddelbuettel <edd@debian.org>
2+
3+
* inst/examples/install2.r: Support options `--quiet` and `--verbose`
4+
as proposed by Zivan Karaman in #124
5+
16
2025-05-20 Dirk Eddelbuettel <edd@debian.org>
27

38
* inst/examples/deadliners.r: Support column width override

inst/examples/install2.r

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (C) 2011 - 2014 Dirk Eddelbuettel
66
# Copyright (C) 2014 - 2017 Carl Boettiger and Dirk Eddelbuettel
7-
# Copyright (C) 2018 - 2023 Carl Boettiger, Dirk Eddelbuettel, Brandon Bertelsen, and SHIMA Tatsuya
7+
# Copyright (C) 2018 - 2025 Carl Boettiger, Dirk Eddelbuettel, Brandon Bertelsen, and SHIMA Tatsuya
88
#
99
# Released under GPL (>= 2)
1010

@@ -15,7 +15,7 @@ library(docopt)
1515
libloc <- .libPaths()[1]
1616

1717
## configuration for docopt
18-
doc <- paste0("Usage: install2.r [-l LIBLOC] [-h] [-x] [-s] [-d DEPS] [-n NCPUS] [-r REPOS...] [-m METHOD] [-t TYPE] [--error] [--] [PACKAGES ...]
18+
doc <- paste0("Usage: install2.r [-l LIBLOC] [-h] [-x] [-s] [-d DEPS] [-n NCPUS] [-r REPOS...] [-m METHOD] [-t TYPE] [--error] [--quiet] [--verbose] [--] [PACKAGES ...]
1919
2020
-l --libloc LIBLOC location in which to install [default: ", libloc, "]
2121
-d --deps DEPS install suggested dependencies as well [default: NA]
@@ -25,6 +25,8 @@ doc <- paste0("Usage: install2.r [-l LIBLOC] [-h] [-x] [-s] [-d DEPS] [-n NCPUS]
2525
-s --skipinstalled skip installing already installed packages [default: FALSE]
2626
-m --method METHOD method to be used for downloading files [default: auto]
2727
-t --type TYPE installation type as used by `install.packages` [default: getOption]
28+
-q --quiet run installation with `quiet` option set [default: FALSE]
29+
-v --verbose run installation with `verbose` option set [default: FALSE]
2830
-h --help show this help text
2931
-x --usage show help and short example usage")
3032
opt <- docopt(doc) # docopt parsing
@@ -110,7 +112,7 @@ install_packages2 <- function(pkgs, ..., error = FALSE, skipinstalled = FALSE) {
110112
isMatchingFile <- function(f) (file.exists(f) && grepl("(\\.tar\\.gz|\\.tgz|\\.zip)$", f)) || (f == ".")
111113

112114
## helper function which switches to local (ie NULL) repo if matching file is presented
113-
installArg <- function(f, lib, rep, dep, iopts, error, skipinstalled, ncpus, method, type) {
115+
installArg <- function(f, lib, rep, dep, iopts, error, skipinstalled, ncpus, method, type, quiet, verbose) {
114116
install_packages2(pkgs=f,
115117
lib=lib,
116118
repos=if (isMatchingFile(f)) NULL else rep,
@@ -120,7 +122,9 @@ installArg <- function(f, lib, rep, dep, iopts, error, skipinstalled, ncpus, met
120122
method = method,
121123
type = type,
122124
error = error,
123-
skipinstalled = skipinstalled)
125+
skipinstalled = skipinstalled,
126+
quiet = quiet,
127+
verbose = verbose)
124128
}
125129

126130
## strip out arguments to be passed to R CMD INSTALL
@@ -147,7 +151,8 @@ isLocal <- sapply(opt$PACKAGES, isMatchingFile)
147151
## possibly in parallel using up to ncpus)
148152
if (any(isLocal)) {
149153
sapply(opt$PACKAGES, installArg, opt$libloc, opt$repos, opt$deps,
150-
installOpts, opt$error, opt$skipinstalled, opt$ncpus, opt$method, opt$type)
154+
installOpts, opt$error, opt$skipinstalled, opt$ncpus, opt$method, opt$type,
155+
opt$quiet, opt$verbose)
151156
} else {
152157
install_packages2(pkgs = opt$PACKAGES,
153158
lib = opt$libloc,
@@ -158,7 +163,9 @@ if (any(isLocal)) {
158163
method = opt$method,
159164
type = opt$type,
160165
error = opt$error,
161-
skipinstalled = opt$skipinstalled)
166+
skipinstalled = opt$skipinstalled,
167+
quiet = opt$quiet,
168+
verbose = opt$verbose)
162169
}
163170

164171
## clean up any temp file containing CRAN directory information

0 commit comments

Comments
 (0)