Skip to content

Commit b97c53e

Browse files
committed
cli formatting
1 parent 1ba5808 commit b97c53e

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

R/load_tree_data.R

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ load_tree_data <- function(src, table = NULL, columns = DEFAULT_TREE_COLUMNS,
116116
stop("'src' must be a single character string")
117117

118118
if (!gdalraster::ogr_ds_exists(src)) {
119-
cli::cli_alert_danger("connection to {.path {src}} failed")
119+
cli::cli_alert_danger("connection to {.val {src}} failed")
120120
stop("could not connect to 'src'", call. = FALSE)
121121
}
122122

123123
src_fmt <- gdalraster::ogr_ds_format(src)
124124
if (is.null(src_fmt)) {
125-
cli::cli_alert_danger("unsupported format: {.path {src}}")
125+
cli::cli_alert_danger("unsupported format: {.val {src}}")
126126
stop("'src' is not recognized as a supported format", call. = FALSE)
127127
}
128128

@@ -155,9 +155,9 @@ load_tree_data <- function(src, table = NULL, columns = DEFAULT_TREE_COLUMNS,
155155
if (gdalraster::ogr_field_index(src, tbl_tmp, "DIST") < 0 ||
156156
gdalraster::ogr_field_index(src, tbl_tmp, "AZIMUTH") < 0) {
157157

158-
cli::cli_alert_warning(
159-
c("the data source does not have ",
160-
"{.field DIST} and/or {.field AZIMUTH}"))
158+
cli::cli_alert_warning(paste0(
159+
"The data source does not have {.field DIST} and/or ",
160+
"{.field AZIMUTH}."))
161161

162162
columns <- columns[!columns %in% c("DIST", "AZIMUTH")]
163163
if (length(columns) == 0)
@@ -212,7 +212,7 @@ load_tree_data <- function(src, table = NULL, columns = DEFAULT_TREE_COLUMNS,
212212
gdalraster::pop_error_handler()
213213

214214
if (!methods::is(ds, "Rcpp_GDALVector")) {
215-
cli::cli_alert_danger("Failed to access tree data in {.path {src}}")
215+
cli::cli_alert_danger("Failed to access tree data in {.val {src}}")
216216
if (!is.null(sql))
217217
stop("execute SQL failed on 'src'", call. = FALSE)
218218
else
@@ -224,8 +224,7 @@ load_tree_data <- function(src, table = NULL, columns = DEFAULT_TREE_COLUMNS,
224224
if (is.null(sql) && !is.null(columns) && columns[1] != "")
225225
ds$setSelectedFields(columns)
226226

227-
cli::cli_progress_step("Fetching tree data...",
228-
msg_done = "Fetching tree data.")
227+
cli::cli_progress_step("Fetching tree data")
229228
d <- ds$fetch(-1)
230229
cli::cli_progress_done()
231230

R/process_tree_data.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ process_tree_data <- function(tree_table, stem_map = TRUE, full_output = TRUE,
112112
out[[j]] <- rep_len(NA_real_, num_plots)
113113
}
114114

115+
orig_show_after <- getOption("cli.progress_show_after")
116+
options(cli.progress_show_after = 0)
117+
115118
cli::cli_progress_bar(
116-
"Processing...",
119+
"Processing",
117120
format_done = paste0(
118121
"{cli::col_green(cli::symbol$tick)} Processed ",
119122
"{.val {cli::pb_total}} plots in {cli::pb_elapsed}."),
@@ -132,5 +135,7 @@ process_tree_data <- function(tree_table, stem_map = TRUE, full_output = TRUE,
132135
}
133136
cli::cli_progress_done()
134137

138+
options(cli.progress_show_after = orig_show_after)
139+
135140
as.data.frame(out)
136141
}

0 commit comments

Comments
 (0)