Skip to content

Commit 5c97ad1

Browse files
committed
further fixes for issue #44
1 parent 02cf319 commit 5c97ad1

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

R/Pattern.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ Pattern <- setRefClass( "Pattern"
6262
counts <- table(nms)
6363
for (e in child){
6464
if (isTRUE(unname(counts[as.character(e)] > 1))){
65-
if (class(e)=="Argument" ||(class(e)=="Option" && e$argcount>0)){
65+
if (inherits(e,"Argument") ||(inherits(e,"Option") && e$argcount>0)){
6666
if (is.null(e$value)){
6767
e$value <- list()
68-
} else if (class(e$value) != "list"){
68+
} else if (!inherits(e$value,"list")){
6969
e$value <- as.list(e$value)
7070
}
7171
}
72-
if ( class(e) == "Command"
73-
|| (class(e) == "Option" && e$argcount == 0)){
72+
if ( inherits(e,"Command")
73+
|| (inherits(e,"Option") && e$argcount == 0)){
7474
e$value <- 0L
7575
}
7676
}
@@ -100,12 +100,12 @@ Pattern <- setRefClass( "Pattern"
100100
idx <- which(m > 0L)[1]
101101
child <- .children[[idx]]
102102
.children <- .children[-idx]
103-
if (class(child) == "Either"){
103+
if (inherits(child,"Either")){
104104
for (ci in child$children){
105105
group <- c(ci, .children)
106106
groups[[length(groups)+1]] <- group
107107
}
108-
} else if (class(child) == "OneOrMore"){
108+
} else if (inherits(child,"OneOrMore")){
109109
group <- c(child$children, child$children, .children)
110110
groups[[length(groups)+1]] <- group
111111
} else {
@@ -242,7 +242,7 @@ Argument <- setRefClass("Argument", contains="Pattern"
242242
return(matched(TRUE, left, collected))
243243
}
244244
same_name <- Filter(function(a){
245-
class(a) == "Argument" && identical(a$name(), name())
245+
inherits(a,"Argument") && identical(a$name(), name())
246246
}
247247
, collected)
248248
if (length(same_name)){

R/pkg.R renamed to R/docopt-package.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@
55
#'
66
#' For more information see http://docopt.org
77
#'
8-
#' @name docopt-package
98
#' @importFrom utils tail str
10-
#' @docType package
11-
{}
9+
"_PACKAGE"

R/docopt.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ docopt <- function( doc, args=commandArgs(TRUE), name=NULL, help=TRUE, version=N
5656
pattern <- parse_pattern(formal_usage(usage), pot_options)
5757
for (anyopt in pattern$flat("AnyOptions")){
5858
#TODO remove options that are present in pattern
59-
if (class(anyopt) == "AnyOptions") anyopt$children <- pot_options$options
59+
if (inherits(anyopt,"AnyOptions")) anyopt$children <- pot_options$options
6060
}
6161

6262
args <- parse_args(args, pot_options)
@@ -100,9 +100,9 @@ docopt <- function( doc, args=commandArgs(TRUE), name=NULL, help=TRUE, version=N
100100
return(o$long)
101101
}
102102
""
103-
}) |>
104-
sQuote() |>
105-
paste(collapse=", ")
103+
})
104+
105+
m_args <- paste(sQuote(m_args), collapse=", ")
106106

107107
stop("Unknown arguments: ",m_args, call. = FALSE)
108108
# stop(doc, call. = FALSE)

man/docopt-package.Rd

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)