trevorld / r-argparse
Showing 1 of 6 files from the diff.
Other files ignored by Codecov
DESCRIPTION has changed.
inst/COPYRIGHTS has changed.
NEWS.md has changed.
README.rst has changed.

@@ -118,7 +118,7 @@
Loading
118 118
            private$n_subparsers <- private$n_subparsers + 1
119 119
            private$python_code$append(sprintf("%s = %s.add_parser(%s)",
120 120
                            parser_name, private$name,
121 -
                            convert_..._to_arguments("add_argument", ...)))
121 +
                            convert_..._to_arguments("ArgumentParser", ...)))
122 122
            Parser$new(private$python_code, parser_name)
123 123
        }
124 124
    ),
@@ -150,8 +150,7 @@
Loading
150 150
                .stop(message, "non-ascii character error:")
151 151
            } else if (any(grepl("^SyntaxError: positional argument follows keyword argument", output)) ||
152 152
                       grepl("^SyntaxError: non-keyword arg after keyword arg", output[2])) {
153 -
                message <- paste("Positional argument following keyword argument.",
154 -
                                 "Please note ``ArgumentParser`` only accepts keyword arguments.")
153 +
                message <- "Positional argument following keyword argument."
155 154
                .stop(message, "syntax error:")
156 155
            } else if (grepl("^\\{", output)) {
157 156
                args <- jsonlite::fromJSON(paste(output, collapse = ""))
@@ -240,7 +239,7 @@
Loading
240 239
    argument_list <- list(...)
241 240
    argument_names <- names(argument_list)
242 241
    if (is.null(argument_names))
243 -
        argument_names <- rep("", length(argument_list))
242 +
        argument_names <- rep_len("", length(argument_list))
244 243
    equals <- ifelse(argument_names == "", "", "=")
245 244
    proposed_arguments <- c()
246 245
    for (ii in seq_along(argument_list)) {
@@ -264,7 +263,7 @@
Loading
264 263
    }
265 264
    # Set right default prog name if not specified, if possible
266 265
    # Do last to not screw up other fixes with prog insertion
267 -
    if (mode == "ArgumentParser" && all(!grepl("prog=", proposed_arguments))) {
266 +
    if (mode == "ArgumentParser" && needs_prog(argument_names)) {
268 267
        prog <- get_Rscript_filename()
269 268
        if (is.na(prog)) prog <- "PROGRAM"
270 269
        proposed_arguments <- c(sprintf("prog='%s'", prog), proposed_arguments)
@@ -272,6 +271,18 @@
Loading
272 271
    return(paste(proposed_arguments, collapse = ", "))
273 272
}
274 273
274 +
needs_prog <- function(argument_names) {
275 +
    if (length(argument_names) == 0L) {
276 +
        TRUE
277 +
    } else if (argument_names[1L] == "") {
278 +
        FALSE
279 +
    } else if (any(argument_names == "prog")) {
280 +
        FALSE
281 +
    } else {
282 +
        TRUE
283 +
    }
284 +
}
285 +
275 286
# Manually copied over from getopt to eliminate it as a dependency
276 287
get_Rscript_filename <- function() { # nolint
277 288
    prog <- sub("--file=", "", grep("--file=", commandArgs(), value = TRUE)[1])
Files Coverage
R/argparse.R 94.23%
Project Totals (1 files) 94.23%
oqq41l5k2nly8d37

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading