Open shabbychef opened 8 years ago
Sounds reasonable. This is one approach that sounds promising. Passing a named list may also be appealing or a list of paired vectors (though this is a lot of typing).
Can you share your dirty version?
I like the suggestion. The main point of pacman is to make things easier for the user and if it gets a little difficult to manage when scaling that doesn't help anybody. A named list or list of pairs would be easy to implement but might make it more tedious for the user. I like the suggestion for the form. I'm not sure the best way to handle something like foo>=0.2.0 if versions 0.2.0 and 0.3.0 and 1.0.0 exist in the world and say 1.0.0 isn't backwards compatible. Might just be easiest to allow specifying the version in the string but requiring exact versions be specified and if nothing is specified then grab the newest version?
Not my best work, but here's the hack:
# packages is a char array of the form
# c('package','package >= version')
p_i_v_new <- function(packages) {
require(pacman)
pnames <- gsub('\\s*>.+$','',packages)
hasvers <- grepl('>',packages)
vernums <- rep('0.0.0',length(packages))
if (any(hasvers)) {
vernums[hasvers] <- gsub('^.+>=?\\s*','',packages[hasvers])
}
p_install_version(pnames,vernums)
}
# test it:
p_i_v_new(c('dplyr>=0.5','drat>=0.2.0','xts','zoo','fortunes>=1.5'))
The interface for
p_install_version
does, in my mind, scale to a large number of packages. While this looks fine:Things get funny for a large number of packages as the two input can get out of sync and hard to maintain:
Maybe better would be the somewhat 'standard' form of including the version dependency in the string:
Without a
>=
(or>
?), it would be understood that the requirement is simply>=0.0.0
.(I have a quick and dirty implementation based on
grepl
andgsub
andp_install_version
, but the form of the input has to be nailed down first.)