diff --git a/.Rbuildignore b/.Rbuildignore index a1320b1..a456a60 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1 +1,4 @@ README.rst +^\.travis\.yml$ +^.*\.Rproj$ +^\.Rproj\.user$ diff --git a/.gitignore b/.gitignore index a2d973e..65a33ef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *.swp *.timestamp *.rst +.Rproj.user +/.Rhistory diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..bfa7a21 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,24 @@ +# Sample .travis.yml for R projects. +# +# See README.md for instructions, or for more configuration options, +# see the wiki: +# https://github.com/craigcitro/r-travis/wiki + +language: c +script: ./travis-tool.sh run_tests +env: + global: + - R_BUILD_ARGS="--no-manual" + - R_CHECK_ARGS="--no-manual --as-cran" + - WARNINGS_ARE_ERRORS=1 +before_install: + - curl -OL http://raw.github.com/craigcitro/r-travis/master/scripts/travis-tool.sh + - chmod 755 ./travis-tool.sh + - ./travis-tool.sh bootstrap + - ./travis-tool.sh install_aptget rst2pdf +install: + - ./travis-tool.sh install_deps +notifications: + email: + on_success: change + on_failure: change diff --git a/R/optparse.R b/R/optparse.R index 28149c7..5fdbfbf 100644 --- a/R/optparse.R +++ b/R/optparse.R @@ -400,7 +400,7 @@ parse_args <- function(object, args = commandArgs(trailingOnly = TRUE), } if(options_list[["help"]] & print_help_and_exit) { print_help(object) - quit(status=1) + stop("help requested") } if(positional_arguments) { return(list(options = options_list, args = arguments_positional)) diff --git a/inst/tests/test-optparse.R b/inst/tests/test-optparse.R index 26d5e06..cfedbfa 100644 --- a/inst/tests/test-optparse.R +++ b/inst/tests/test-optparse.R @@ -72,6 +72,7 @@ test_that("parse_args works as expected", { sort_list(list(options = list(add_numbers = FALSE, help = FALSE), args = c("-add_numbers", "example.txt")))) expect_that(parse_args(parser, args = c("-add_numbers", "example.txt")), throws_error()) + expect_that(parse_args(parser, args = c("--help")), throws_error()) }) # Bug found by Miroslav Posta test_that("test using numeric instead of double", { diff --git a/optparse.Rproj b/optparse.Rproj new file mode 100644 index 0000000..cf43990 --- /dev/null +++ b/optparse.Rproj @@ -0,0 +1,16 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 4 +Encoding: UTF-8 + +RnwWeave: knitr +LaTeX: pdfLaTeX + +BuildType: Package +PackageInstallArgs: --no-multiarch