From de5626c3822ab89fa0d5e0ef4479262dbfdf50df Mon Sep 17 00:00:00 2001 From: Trevor L Davis Date: Tue, 19 Nov 2024 10:42:02 -0800 Subject: [PATCH] fix: Wrap `python_cmd` with `normalizePath()` * `ArgumentParser()`'s `python_cmd` argument is now wrapped by `normalizePath(mustWork = FALSE)`. --- DESCRIPTION | 5 +++-- NEWS.md | 5 +++++ R/argparse.R | 23 ++++++++++++----------- _pkgdown.yml | 2 ++ man/ArgumentParser.Rd | 22 +++++++++++----------- 5 files changed, 33 insertions(+), 24 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index fd8626e..c0d1cfd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: argparse Type: Package Title: Command Line Optional and Positional Argument Parser -Version: 2.2.3 -Authors@R: c(person("Trevor L", "Davis", role=c("aut", "cre"), +Version: 2.2.4-0 +Authors@R: c(person("Trevor L.", "Davis", role=c("aut", "cre"), email="trevor.l.davis@gmail.com", comment = c(ORCID = "0000-0001-6341-4639")), person("Allen", "Day", role="ctb", comment="Some documentation and examples ported from the getopt package."), @@ -28,5 +28,6 @@ Suggests: rmarkdown, testthat VignetteBuilder: knitr +Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.1 Encoding: UTF-8 diff --git a/NEWS.md b/NEWS.md index b237bd6..6a1f247 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +argparse 2.2.4 +============== + +* `ArgumentParser()`'s `python_cmd` argument is now wrapped by `normalizePath(mustWork = FALSE)`. + argparse 2.2.3 ============== diff --git a/R/argparse.R b/R/argparse.R index dfa55bb..3c10c82 100644 --- a/R/argparse.R +++ b/R/argparse.R @@ -22,22 +22,22 @@ #' Create a command line parser #' -#' \code{ArgumentParser} creates a parser object that acts as -#' a wrapper to Python's argparse module +#' `ArgumentParser()` creates a parser object that acts as +#' a wrapper to Python's `argparse` module #' -#' @param ... Arguments cleaned and passed to Pythons argparse.ArgumentParser() -#' @param python_cmd Python executable for \code{argparse} to use. -#' Must have argparse and json modules (automatically included Python 2.7 and 3.2+). +#' @param ... Arguments cleaned and passed to Pythons `argparse.ArgumentParser()` +#' @param python_cmd Python executable for `argparse` to use. +#' Must have `argparse` and `json` modules (automatically bundled with Python 2.7 and 3.2+). #' If you need Unicode argument support then you must use Python 3.0+. -#' Default will be to use \code{findpython} package to find suitable Python binary. -#' @return \code{ArgumentParser} returns a parser object which contains -#' an \code{add_argument} function to add arguments to the parser, -#' a \code{parse_args} function to parse command line arguments into -#' a list, a \code{print_help} and \code{print_usage} function to print +#' Default will be to use `findpython` package to find suitable Python binary. +#' @return `ArgumentParser()` returns a parser object which contains +#' an `add_argument()` function to add arguments to the parser, +#' a `parse_args()` function to parse command line arguments into +#' a list, a `print_help()` and a `print_usage()` function to print #' usage information. See code examples, package vignette, #' and corresponding python module for more information on how to use it. #' -#' @references Python's \code{argparse} library, which this package is based on, +#' @references Python's `argparse` library, which this package is based on, #' is described here: \url{https://docs.python.org/3/library/argparse.html} #' #' @examples @@ -392,6 +392,7 @@ find_python_cmd <- function(python_cmd = NULL) { python_cmd <- findpython::find_python_cmd(required_modules = required_modules) } } + python_cmd <- normalizePath(python_cmd, mustWork = FALSE) python_cmd } diff --git a/_pkgdown.yml b/_pkgdown.yml index 398e522..f8de8a0 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -2,3 +2,5 @@ destination: "../../websites/R/argparse/" url: "https://trevorldavis.com/R/argparse" development: mode: auto +template: + bootstrap: 5 diff --git a/man/ArgumentParser.Rd b/man/ArgumentParser.Rd index e939d4f..7b527b7 100644 --- a/man/ArgumentParser.Rd +++ b/man/ArgumentParser.Rd @@ -7,24 +7,24 @@ ArgumentParser(..., python_cmd = NULL) } \arguments{ -\item{...}{Arguments cleaned and passed to Pythons argparse.ArgumentParser()} +\item{...}{Arguments cleaned and passed to Pythons \code{argparse.ArgumentParser()}} \item{python_cmd}{Python executable for \code{argparse} to use. -Must have argparse and json modules (automatically included Python 2.7 and 3.2+). +Must have \code{argparse} and \code{json} modules (automatically bundled with Python 2.7 and 3.2+). If you need Unicode argument support then you must use Python 3.0+. Default will be to use \code{findpython} package to find suitable Python binary.} } \value{ -\code{ArgumentParser} returns a parser object which contains - an \code{add_argument} function to add arguments to the parser, - a \code{parse_args} function to parse command line arguments into - a list, a \code{print_help} and \code{print_usage} function to print - usage information. See code examples, package vignette, - and corresponding python module for more information on how to use it. +\code{ArgumentParser()} returns a parser object which contains +an \code{add_argument()} function to add arguments to the parser, +a \code{parse_args()} function to parse command line arguments into +a list, a \code{print_help()} and a \code{print_usage()} function to print +usage information. See code examples, package vignette, +and corresponding python module for more information on how to use it. } \description{ -\code{ArgumentParser} creates a parser object that acts as -a wrapper to Python's argparse module +\code{ArgumentParser()} creates a parser object that acts as +a wrapper to Python's \code{argparse} module } \examples{ @@ -45,5 +45,5 @@ if (argparse:::detects_python()) { } \references{ Python's \code{argparse} library, which this package is based on, - is described here: \url{https://docs.python.org/3/library/argparse.html} +is described here: \url{https://docs.python.org/3/library/argparse.html} }