#' Command line interface argument parsing functions
#'
#' @name cli
#' @keywords internal
#'
#' @note Updated 2023-01-27.
NULL
## Updated 2023-02-13.
.cliSyntacticRename <- function(fun) {
assert(requireNamespaces("syntactic"))
parse <- parseArgs(
flags = c(
"dry-run",
"quiet",
"recursive"
),
positional = TRUE
)
positional <- parse[["positional"]]
flags <- parse[["flags"]]
args <- list(
"path" = .unescapePos(positional),
"recursive" = isSubset("recursive", flags),
"fun" = fun,
"quiet" = isSubset("quiet", flags),
"dryRun" = isSubset("dry-run", flags)
)
do.call(what = syntactic::syntacticRename, args = args)
}
#' @rdname cli
#' @export
cliCamelCase <- function() {
.cliSyntacticRename(fun = "camelCase")
}
#' @rdname cli
#' @export
cliCheckSystem <- function() {
assert(!hasPositionalArgs())
checkSystem()
}
#' @rdname cli
#' @export
cliDockerBuildAllTags <- function() {
parse <- parseArgs(
required = c("local", "remote"),
optional = "days",
flags = "force",
positional = FALSE
)
args <- list(
"local" = parse[["required"]][["local"]],
"remote" = parse[["required"]][["remote"]],
"force" = "force" %in% parse[["flags"]]
)
optional <- parse[["optional"]]
if (!is.null(optional)) {
if (isSubset("days", names(optional))) {
args[["days"]] <- as.numeric(optional[["days"]])
}
}
do.call(what = dockerBuildAllTags, args = args)
}
#' @rdname cli
#' @export
cliFindAndMoveInSequence <- function() {
pos <- positionalArgs()
args <- list(
"sourceDir" = realpath(pos[[1L]]),
"targetDir" = realpath(pos[[2L]])
)
do.call(what = findAndMoveInSequence, args = args)
}
#' @rdname cli
#' @export
cliKebabCase <- function() {
.cliSyntacticRename(fun = "kebabCase")
}
#' @rdname cli
#' @export
cliPruneAppBinaries <- function() {
assert(!hasPositionalArgs())
pruneAppBinaries()
}
#' @rdname cli
#' @export
cliPruneApps <- function() {
assert(!hasPositionalArgs())
pruneApps()
}
#' @rdname cli
#' @export
cliSnakeCase <- function() {
.cliSyntacticRename(fun = "snakeCase")
}
#' @rdname cli
#' @export
cliUpdatePackages <- function() {
assert(!hasPositionalArgs())
requireNamespaces("AcidDevTools")
AcidDevTools::updatePackages()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.