From 351e44ee2896810a510e3a3714b459d3d41045b8 Mon Sep 17 00:00:00 2001 From: Tom Elliott Date: Wed, 22 Jan 2025 20:58:39 +1300 Subject: [PATCH] remove cli --- DESCRIPTION | 1 - R/function.R | 9 ++++----- R/helpers.R | 12 ++++++++++++ R/types.R | 14 +++----------- 4 files changed, 19 insertions(+), 17 deletions(-) create mode 100644 R/helpers.R diff --git a/DESCRIPTION b/DESCRIPTION index e34de35..df98b39 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -12,7 +12,6 @@ Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.1 Config/testthat/edition: 3 Imports: - cli, rlang, Rserve Suggests: diff --git a/R/function.R b/R/function.R index 40d17c4..41825bf 100644 --- a/R/function.R +++ b/R/function.R @@ -82,19 +82,18 @@ ts_function <- function(f, ..., result = ts_void()) { } - #' @export print.ts_function <- function(x, ...) { - cli::cli_h3("Ocap function") + h3("Ocap function") - cli::cli_text("Arguments:") + cat("Arguments:\n") args <- lapply(x$args, \(z) z$input_type) lapply(names(args), \(n) { cat("- ", n, ": ", args[[n]], "\n", sep = "") }) - cli::cli_text("\n\n") + cat("\n\n") - cli::cli_text("Return type:") + cat("Return type:\n") cat(x$result$return_type) } diff --git a/R/helpers.R b/R/helpers.R new file mode 100644 index 0000000..eaee05f --- /dev/null +++ b/R/helpers.R @@ -0,0 +1,12 @@ +h3 <- function(x) { + cat("\n---", x, "\n") +} + + + +format_js <- function(x) { + if (!requireNamespace("js", quietly = TRUE)) { + return(x) + } + js::uglify_reformat(x, beautify = TRUE) +} diff --git a/R/types.R b/R/types.R index 149c10c..ee02868 100644 --- a/R/types.R +++ b/R/types.R @@ -27,21 +27,20 @@ ts_object <- function(input_type = "any", #' @export print.ts_object <- function(x, ...) { # name <- deparse(substitute(x)) - cli::cli_ul() - cli::cli_h3("Input type: ") + h3("Input type: ") if (nchar(x$input_type) > 50) { cat(format_js(x$input_type), "\n") } else { cat(x$input_type, "\n") } - cli::cli_h3("Return type: ") + h3("Return type: ") if (nchar(x$return_type) > 50) { print(x$return_type) cat(format_js(x$return_type), "\n") } else { cat(x$return_type, "\n") } - cli::cli_end() + cat("\n") } #' @describeIn ts_object Check if an object is a ts object @@ -397,10 +396,3 @@ ts_void <- function() { } ) } - -format_js <- function(x) { - if (!requireNamespace("js", quietly = TRUE)) { - return(x) - } - js::uglify_reformat(x, beautify = TRUE) -}