Wishlist-for-R
Wishlist-for-R copied to clipboard
WISH: Make it easier to get a clean package version string from command line (CLI)
Issue
$ Rscript -e "packageVersion('future')"
[1] '1.7.0.9000'
$ Rscript -e "as.character(packageVersion('future'))"
[1] "1.7.0.9000"
The solution involves understanding R and now numeric_version
objects are print()
:ed, e.g.
$ Rscript -e "cat(as.character(packageVersion('future')))"
1.7.0.9000
$ Rscript -e "cat(packageDescription('future')[['Version']])"
1.7.0-9000
Suggestion
I don't know what the best solution would be here. Maybe update cat()
so the following works:
$ Rscript -e "cat(packageVersion('future'))"
Error in cat(packageVersion("future")) :
argument 1 (type 'list') cannot be handled by 'cat'
This seems like it would be tough to do. cat is not (AFAIK) a generic (implicit or otherwise) and in general it working on a list doesn't make much sense to me. It doesn't seem like having to call as.character on it is that bad...
On Thu, Mar 1, 2018 at 1:49 PM, Henrik Bengtsson [email protected] wrote:
Issue
$ Rscript -e "packageVersion('future')" [1] '1.7.0.9000' $ Rscript -e "as.character(packageVersion('future'))" [1] "1.7.0.9000"
The solution involves understanding R and now numeric_version objects are print():ed, e.g.
$ Rscript -e "cat(as.character(packageVersion('future')))"1.7.0.9000 $ Rscript -e "cat(packageDescription('future')[['Version']])"1.7.0-9000
Suggestion
I don't know what the best solution would be here. Maybe update cat() so the following works:
$ Rscript -e "cat(packageVersion('future'))"Error in cat(packageVersion("future")) : argument 1 (type 'list') cannot be handled by 'cat'
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/HenrikBengtsson/Wishlist-for-R/issues/58, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3dsdmvHhan8nyKI9g2KOCPOIFVRF8Lks5taGzcgaJpZM4SZDCc .
-- Gabriel Becker, Ph.D Scientist Bioinformatics and Computational Biology Genentech Research
I added this as an "issue" because it's very noisy for non-R developers, e.g. someone who write a pipeline in bash/Python/Ruby, ... and who needs to query the version of dependent R package.
Maybe print()
could behave differently in non-interactive mode/for simple objects. OTH, that'll introduce inconsistent behavior and possible be even more confusing. It's basically the same problem where you cannot easy call R from the CLI for quick calcs etc, i.e.
$ Rscript -e 1+2
[1] 3
This makes it unnecessarily hard using R in pipes / redirects. Maybe there could be an option()
to suppress any print()
prefix and be able to control this option via a CLI option, e.g.
$ Rscript --simplify -e 1+2
3
$ Rscript -s -e 1+2
3
$ Rscript -se 1+2
3
Looks like this is already in there, just super obscure (though it is mentioned in the help for print):
tools::.print.via.format(packageVersion("fastdigest")) 0.6.3