Skip to content
Open
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.9003
Authors@R:
person(
given = "Jordan Mark",
Expand All @@ -16,7 +16,7 @@ License: MIT + file LICENSE
Encoding: UTF-8
Language: en-US
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.3
Depends:
R (>= 3.6)
Imports:
Expand Down
57 changes: 28 additions & 29 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 @@
execute = function(self, ca) {
if (isTRUE(self$get_value())) {
ca$help()
return(exit())

Check warning on line 50 in R/arg.R

View workflow job for this annotation

GitHub Actions / lint

file=R/arg.R,line=50,col=9,[return_linter] Use implicit return behavior; explicit return() is not needed.
}
}
)
Expand All @@ -68,7 +67,7 @@
if (isTRUE(self$get_value())) {
.Deprecated("For {scribe} package version, use ---version instead")
ca$version()
return(exit())

Check warning on line 70 in R/arg.R

View workflow job for this annotation

GitHub Actions / lint

file=R/arg.R,line=70,col=9,[return_linter] Use implicit return behavior; explicit return() is not needed.
}
}
)
Expand All @@ -78,19 +77,19 @@

# 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 +313,7 @@
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 +373,7 @@
nm
}

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

Expand Down Expand Up @@ -508,7 +507,7 @@
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
9 changes: 4 additions & 5 deletions R/class-command-args.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' {scribe} command arguments
#'
#' Reference class object for managing command line arguments.
Expand Down Expand Up @@ -205,13 +204,13 @@ scribeCommandArgs$methods(

add_argument = function(
...,
action = arg_actions(),
action = arg_actions(),
default = NULL,
convert = scribe_convert(),
n = NA_integer_,
info = NULL,
n = NA_integer_,
info = NULL,
options = list(),
stop = c("none", "hard", "soft"),
stop = c("none", "hard", "soft"),
execute = invisible
) {
"Add a \\link{scribeArg} to \\code{args}
Expand Down
Loading
Loading