Skip to content

Commit

Permalink
+ peek()
Browse files Browse the repository at this point in the history
  • Loading branch information
romainfrancois committed Feb 3, 2024
1 parent 06fc47d commit d33a361
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 2 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
URL: https://github.com/tadascience/snitch, http://tada.science/snitch/
BugReports: https://github.com/tadascience/snitch/issues
Imports:
cli
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Generated by roxygen2: do not edit by hand

export(informant)
export(peek)
23 changes: 21 additions & 2 deletions R/peek.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
#' @export
informant <- function() {
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")

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()
#'
#' @export
peek <- function() {
cat("hello\n")
peek <- function(fun) {
fun <- substitute(fun)
trace(fun, tracer = snitch::informant)
}
2 changes: 1 addition & 1 deletion man/peek.Rd

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

0 comments on commit d33a361

Please sign in to comment.