Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check
name: R-CMD-check.yaml

permissions: read-all

jobs:
R-CMD-check:
Expand All @@ -29,7 +30,7 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -47,3 +48,4 @@ jobs:
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
7 changes: 4 additions & 3 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: lint
name: lint.yaml

permissions: read-all

jobs:
lint:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: pkgdown
name: pkgdown.yaml

permissions: read-all

jobs:
pkgdown:
Expand All @@ -19,8 +20,10 @@ jobs:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -39,7 +42,7 @@ jobs:

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.4.1
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
Expand Down
28 changes: 20 additions & 8 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: test-coverage
name: test-coverage.yaml

permissions: read-all

jobs:
test-coverage:
Expand All @@ -15,36 +16,47 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
extra-packages: any::covr, any::xml2
needs: coverage

- name: Test coverage
run: |
covr::codecov(
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
print(cov)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v5
with:
# Fail if error if not on PR, or if on PR and token is given
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
files: ./cobertura.xml
plugins: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: scribe
Title: Command Argument Parsing
Version: 0.3.0.9002
Version: 0.3.0.9004
Authors@R:
person(
given = "Jordan Mark",
Expand All @@ -16,7 +16,6 @@ License: MIT + file LICENSE
Encoding: UTF-8
Language: en-US
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
Depends:
R (>= 3.6)
Imports:
Expand All @@ -34,3 +33,4 @@ VignetteBuilder: knitr
URL: https://jmbarbone.github.io/scribe/, https://github.com/jmbarbone/scribe
BugReports: https://github.com/jmbarbone/scribe/issues
Config/testthat/parallel: true
Config/roxygen2/version: 8.0.0
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ These are not meant to be user accessible.
- `arg$show()` now prints values of class `"scribe_empty_value"` as `<empty>`
- `arg$add_argument()` correctly passes all method arguments [#78](https://github.com/jmbarbone/scribe/issues/78)
- `ca$parse()` correctly deals with new arguments that nave the same _name_ as ones in `included` [#80](https://github.com/jmbarbone/scribe/issues/80)
- internal documentation updates

# scribe 0.3.0

Expand Down
63 changes: 30 additions & 33 deletions R/arg.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' New command argument
#'
#' Make a new [scribeArg] object
Expand All @@ -13,25 +12,25 @@
#' @family scribe
#' @export
new_arg <- function(
aliases = "",
action = arg_actions(),
default = NULL,
convert = scribe_convert(),
n = NA_integer_,
info = NULL,
options = list(),
stop = c("none", "hard", "soft"),
execute = invisible
aliases = "",
action = arg_actions(),
default = NULL,
convert = scribe_convert(),
n = NA_integer_,
info = NULL,
options = list(),
stop = c("none", "hard", "soft"),
execute = invisible
) {
scribeArg$new(
aliases = aliases,
action = action,
action = action,
default = default,
convert = convert,
n = n,
info = info,
n = n,
info = info,
options = options,
stop = stop,
stop = stop,
execute = execute
)
}
Expand All @@ -48,7 +47,7 @@ scribe_help_arg <- function() {
execute = function(self, ca) {
if (isTRUE(self$get_value())) {
ca$help()
return(exit())
exit()
}
}
)
Expand All @@ -68,29 +67,28 @@ scribe_version_arg <- function() {
if (isTRUE(self$get_value())) {
.Deprecated("For {scribe} package version, use ---version instead")
ca$version()
return(exit())
exit()
}
}
)
}

# wrappers ----------------------------------------------------------------

# nolint next: cyclocomp_linter.
arg_initialize <- function(
self,
aliases = "",
action = arg_actions(),
default = NULL,
convert = scribe_convert(),
n = NA_integer_,
info = NA_character_,
options = list(),
stop = c("none", "hard", "soft"),
execute = invisible
self,
aliases = "",
action = arg_actions(),
default = NULL,
convert = scribe_convert(),
n = NA_integer_,
info = NA_character_,
options = list(),
stop = c("none", "hard", "soft"),
execute = invisible
) {
action <- match.arg(action, arg_actions())
info <- info %||% NA_character_
action <- match.arg(action, arg_actions())
info <- info %||% NA_character_
options <- options %||% list()

if (action == "default") {
Expand Down Expand Up @@ -314,7 +312,7 @@ arg_get_help <- function(self) {
list = {
left <- paste(
to_string(self$get_aliases(), sep = ", "),
sprintf("[%s]", if (self$n == 1) "ARG" else sprintf("..%i", self$n))
sprintf("[%s]", if (self$n == 1) "ARG" else sprintf("..%i", self$n))
)

right <- self$info
Expand Down Expand Up @@ -374,7 +372,7 @@ arg_get_name <- function(self, clean = TRUE) {
nm
}

arg_get_action <- function(self) {
arg_get_action <- function(self) {
self$action %||% character()
}

Expand All @@ -400,7 +398,6 @@ arg_is_resolved <- function(self) {

# internal ----------------------------------------------------------------

# nolint next: cyclocomp_linter.
arg_parse_value <- function(self, ca) {
default <-
if (is_arg(self$default)) {
Expand Down Expand Up @@ -508,7 +505,7 @@ is_arg <- function(x) {
methods::is(x, "scribeArg")
}

ARG_PAT <- "^-[a-z]$|^---?[a-z]+$|^--?[a-z](+[-]?[a-z]+)+$" # nolint: object_name_linter, line_length_linter.
ARG_PAT <- "^-[a-z]$|^---?[a-z]+$|^--?[a-z](+[-]?[a-z]+)+$" # nolint: object_name_linter, line_length_linter.

arg_actions <- function() {
c("default", "list", "flag", "dots")
Expand Down
45 changes: 22 additions & 23 deletions R/class-args.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' {scribe} argument
#'
#' ReferenceClass object for managing arguments
Expand Down Expand Up @@ -75,32 +74,32 @@
# nolint next: object_name_linter.
scribeArg <- methods::setRefClass(
"scribeArg",
fields = list(
aliases = "character",
action = "character",
default = "ANY",
convert = "ANY",
n = "integer",
info = "character",
options = "list",
fields = list(
aliases = "character",
action = "character",
default = "ANY",
convert = "ANY",
n = "integer",
info = "character",
options = "list",
positional = "logical",
resolved = "logical",
value = "ANY",
stop = "character",
execute = "function"
resolved = "logical",
value = "ANY",
stop = "character",
execute = "function"
)
)

scribeArg$methods(
initialize = function(
aliases = "",
action = arg_actions(),
action = arg_actions(),
default = NULL,
convert = scribe_convert(),
n = NA_integer_,
info = NA_character_,
n = NA_integer_,
info = NA_character_,
options = list(),
stop = c("none", "hard", "soft"),
stop = c("none", "hard", "soft"),
execute = invisible
) {
"
Expand All @@ -109,15 +108,15 @@ scribeArg$methods(
See \\strong{fields} for parameter information.
"
arg_initialize(
self = .self,
self = .self,
aliases = aliases,
action = action,
action = action,
default = default,
convert = convert,
n = n,
info = info,
n = n,
info = info,
options = options,
stop = stop,
stop = stop,
execute = execute
)
},
Expand Down Expand Up @@ -186,7 +185,7 @@ scribeSuperArg$methods(
}

arg_initialize(
self = .self,
self = .self,
aliases = aliases,
...
)
Expand Down
Loading
Loading