trevorld / r-argparse

command-line optional and positional argument parser
GNU General Public License v2.0
103 stars 11 forks source link

Show program's version with -v/--version #18

Closed dariober closed 6 years ago

dariober commented 6 years ago

Is it possible to show the program's version with -v/--version as in python's argarse?

I tried the following script:

#!/usr/bin/env Rscript

library(argparse)
parser<- ArgumentParser()
parser$add_argument("-v", "--version", action= 'version', version= '1.2.3')
xargs<- parser$parse_args()

Executed as:

./test.R -v

It compiles fine but it doesn't print the version number "1.2.3"

Thank you!

Session info:

sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS release 6.6 (Final)

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8    LC_PAPER=en_GB.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] argparse_1.0.4 proto_1.0.0   

loaded via a namespace (and not attached):
[1] rjson_0.2.15     findpython_1.0.2 getopt_1.20.0   
trevorld commented 6 years ago

Thanks for the report. I'll aim to update this by the end of the year.