Skip to content

Commit

Permalink
Add some cli funtions to NAMESPACE
Browse files Browse the repository at this point in the history
  • Loading branch information
daxkellie committed Dec 20, 2024
1 parent 1c4daa7 commit 65ba6e5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ export(use_metadata)
export(validate_archive)
importFrom(cli,cat_line)
importFrom(cli,cli_abort)
importFrom(cli,cli_bullets)
importFrom(cli,cli_fmt)
importFrom(cli,cli_h2)
importFrom(cli,cli_h3)
importFrom(cli,cli_inform)
importFrom(cli,cli_progress_done)
importFrom(cli,cli_progress_step)
importFrom(cli,cli_progress_update)
importFrom(cli,col_grey)
importFrom(corella,check_dataset)
importFrom(corella,suggest_workflow)
importFrom(curl,form_data)
Expand Down
18 changes: 10 additions & 8 deletions R/use_metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,37 @@
#' @importFrom cli cli_progress_step
#' @importFrom cli cli_progress_done
#' @importFrom cli cli_bullets
#' @importFrom cli cli_fmt
#' @importFrom cli col_grey
#' @export
use_metadata <- function(file, overwrite = FALSE){
if(missing(file)){
cli::cli_progress_step("Creating template file {.file metadata.md}.")
cli_progress_step("Creating template file {.file metadata.md}.")
file <- "metadata.md"
cli::cli_progress_done()
}
if(overwrite){
cli::cli_progress_step("Overwriting existing file {.file {file}}.")
cli_progress_step("Overwriting existing file {.file {file}}.")
write_md(paperbark::metadata_example, file = file)
cli::cli_progress_done()
cli_progress_done()
}else{
if(file.exists(file)){
bullets <- c("File {.file {file}} already exists.",
i = "Use a different filename or set `overwrite = TRUE`") |>
cli::cli_bullets() |>
cli::cli_fmt()
cli_bullets() |>
cli_fmt()

abort(bullets)
}else{
write_md(paperbark::metadata_example, file = file)
}
}

cli::cli_bullets(c(
cli_bullets(c(
v = "File template {.file {file}} saved to top folder in local directory.",
i = paste(
c(" Edit {.file {file}}") |> cli::col_grey(),
c("then use {.fn build_metadata} to build final metadata statement.") |> cli::col_grey()
c(" Edit {.file {file}}") |> col_grey(),
c("then use {.fn build_metadata} to build final metadata statement.") |> col_grey()
)
))

Expand Down
19 changes: 15 additions & 4 deletions man/use_metadata.Rd

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

0 comments on commit 65ba6e5

Please sign in to comment.