Skip to content

Commit

Permalink
Merge pull request #66 from tanho63/use-verbose-option
Browse files Browse the repository at this point in the history
Use verbose option
  • Loading branch information
cboettig authored Apr 26, 2022
2 parents 42eba8c + 600e56f commit f54d041
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: piggyback
Version: 0.1.1.9002
Version: 0.1.1.9003
Title: Managing Larger Data on a GitHub Repository
Description: Because larger (> 50 MB) data files cannot easily be committed to git,
a different approach is required to manage data associated with an analysis in a
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* `pb_upload()` is now the only function that offers (interactively) to create a new release if release is not found. If noninteractive, user must run `pb_new_release()` manually prior to uploading.
* CLI messaging now consistently uses `{cli}` package and no longer uses clisymbols or crayon - this is to align with the imports from the `{gh}` package.
* Documentation updated.
* Add options("piggyback.verbose") TRUE/FALSE to control verbosity/messaging levels.

# piggyback 0.1.1

Expand Down
2 changes: 1 addition & 1 deletion R/pb_delete.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pb_delete <- function(file = NULL,
)
})

cli::cli_alert_info("Deleted {.val {file}} from {.val {tag}} release on {.val {repo}}")
if(getOption("piggyback.verbose", default = TRUE)) cli::cli_alert_info("Deleted {.val {file}} from {.val {tag}} release on {.val {repo}}")

return(invisible(TRUE))
}
5 changes: 3 additions & 2 deletions R/pb_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pb_download <- function(file = NULL,
overwrite = TRUE,
ignore = "manifest.json",
use_timestamps = TRUE,
show_progress = TRUE,
show_progress = getOption("piggyback.verbose", default = TRUE),
.token = gh::gh_token()) {

progress <- httr::progress("down")
Expand Down Expand Up @@ -78,6 +78,7 @@ pb_download <- function(file = NULL,

if (dim(df)[[1]] < 1) {
cli::cli_alert_info("All local files already up-to-date!")
return(invisible(NULL))
}
}

Expand All @@ -89,7 +90,7 @@ pb_download <- function(file = NULL,
overwrite = overwrite,
progress = progress
))
invisible(resp)
return(invisible(resp))
}

## gh() fails on this, so we do with httr. See https://github.com/r-lib/gh/issues/57
Expand Down
14 changes: 6 additions & 8 deletions R/pb_upload.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' only overwriting those files which are older.
#' @param use_timestamps DEPRECATED.
#' @param show_progress logical, show a progress bar be shown for uploading?
#' Defaults to `TRUE`.
#' Defaults to `TRUE` - can also set globally with options("piggyback.verbose")
#' @param .token GitHub authentication token, see `[gh::gh_token()]`
#' @param dir directory relative to which file names should be based, defaults to NULL for current working directory.
#' @examples
Expand All @@ -30,7 +30,7 @@ pb_upload <- function(file,
name = NULL,
overwrite = "use_timestamps",
use_timestamps = NULL,
show_progress = TRUE,
show_progress = getOption("piggyback.verbose", default = TRUE),
.token = gh::gh_token(),
dir = NULL) {

Expand Down Expand Up @@ -86,7 +86,7 @@ pb_upload_file <- function(file,
name = NULL,
overwrite = "use_timestamps",
use_timestamps = NULL,
show_progress = TRUE,
show_progress = getOption("piggyback.verbose", default = TRUE),
.token = gh::gh_token(),
dir = NULL) {

Expand Down Expand Up @@ -122,9 +122,7 @@ pb_upload_file <- function(file,
)

progress <- httr::progress("up")
if (!show_progress) {
progress <- NULL
}
if (!show_progress) progress <- NULL

if (is.null(name)) {
## name is name on GitHub, technically need not be name of local file
Expand Down Expand Up @@ -162,7 +160,7 @@ pb_upload_file <- function(file,
}
}

if (!is.null(progress)) cli::cli_alert_info("Uploading {.file {name}} ...")
if (show_progress) cli::cli_alert_info("Uploading {.file {name}} ...")

r <- httr::POST(sub("\\{.+$", "", df$upload_url[[1]]),
query = list(name = name),
Expand All @@ -172,7 +170,7 @@ pb_upload_file <- function(file,

cat("\n")

if(getOption("piggyback.verbose", default = TRUE)) httr::warn_for_status(r)
if(show_progress) httr::warn_for_status(r)

## Release info changed, so break cache
try({memoise::forget(pb_info)})
Expand Down
4 changes: 2 additions & 2 deletions man/pb_download.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/pb_upload.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f54d041

Please sign in to comment.