Skip to content

Commit

Permalink
fix: Wrap python_cmd with normalizePath()
Browse files Browse the repository at this point in the history
* `ArgumentParser()`'s `python_cmd` argument is now wrapped by `normalizePath(mustWork = FALSE)`.
  • Loading branch information
trevorld committed Nov 19, 2024
1 parent 7e6baca commit de5626c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 24 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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="[email protected]",
comment = c(ORCID = "0000-0001-6341-4639")),
person("Allen", "Day", role="ctb", comment="Some documentation and examples ported from the getopt package."),
Expand All @@ -28,5 +28,6 @@ Suggests:
rmarkdown,
testthat
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
Encoding: UTF-8
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
argparse 2.2.4
==============

* `ArgumentParser()`'s `python_cmd` argument is now wrapped by `normalizePath(mustWork = FALSE)`.

argparse 2.2.3
==============

Expand Down
23 changes: 12 additions & 11 deletions R/argparse.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 2 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ destination: "../../websites/R/argparse/"
url: "https://trevorldavis.com/R/argparse"
development:
mode: auto
template:
bootstrap: 5
22 changes: 11 additions & 11 deletions man/ArgumentParser.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit de5626c

Please sign in to comment.