Skip to content

Commit

Permalink
snitch::fun() instead of peek
Browse files Browse the repository at this point in the history
  • Loading branch information
romainfrancois committed Feb 3, 2024
1 parent a9afadf commit 5d36c94
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by roxygen2: do not edit by hand

export(fun)
export(informant)
export(peek)
22 changes: 13 additions & 9 deletions R/peek.R
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@

#' @export
informant <- function() {
hex_pink <- cli::make_ansi_style("pink")("")

env <- parent.frame()
calls <- sys.calls()

pink <- cli::make_ansi_style("pink")
call <- deparse(calls[[length(calls) - 5L]])

print(cli::rule(col = "pink"))
cat(pink(""), cli::col_silver("call: "), call, "\n")
header <- paste(hex_pink, cli::col_silver("call:"), call)
content <- paste(hex_pink, cli::col_silver("env:"))
txt <- paste(" - ", capture.output(print(ls.str(env))))

print(cli::boxx(
c(header, content, txt),
padding = 1, border_col = "pink"
))

print(cli::rule(col = "pink"))
cat(pink(""), cli::col_silver("env: \n"))
print(ls.str(env))
print(cli::rule(col = "pink"))
invisible()
}

#' Peek function inputs
#'
#' @examples
#' peek()
#' fun(rnorm)
#'
#' @export
peek <- function(fun, tracer = snitch::informant, where = topenv(parent.frame())) {
fun <- function(fun, tracer = snitch::informant, where = topenv(parent.frame())) {
call <- sys.call()
call[[1L]] <- quote(trace)
call$where <- where
Expand Down
8 changes: 4 additions & 4 deletions man/peek.Rd → man/fun.Rd

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

0 comments on commit 5d36c94

Please sign in to comment.