Skip to content

Commit

Permalink
Make it possible to opt-in to original display
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Feb 1, 2024
1 parent d2d2faa commit 3cf26cd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
21 changes: 13 additions & 8 deletions R/chromote.R
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,19 @@ Chromote <- R6Class(

#' @description Summarise the current state of the object.
#' @param ... Ignored
print = function(...) {
state <- if (private$is_active_) "active" else "closed"
ps <- self$get_browser()$get_process()

cat_line("<Chromote> (", state, ")")
cat_line(" URL: ", self$url())
cat_line(" PID: ", ps$get_pid())
cat_line(" Path: ", ps$get_cmdline()[[1]])
print = function(..., verbose = FALSE) {
if (verbose) {
cat(format(self, ...), sep = "\n")
} else {
state <- if (private$is_active_) "active" else "closed"
ps <- self$get_browser()$get_process()

cat_line("<Chromote> (", state, ")")
cat_line(" URL: ", self$url())
cat_line(" PID: ", ps$get_pid())
cat_line(" Path: ", ps$get_cmdline()[[1]])
}
invisible(self)
},

#' @field default_timeout Default timeout in seconds for \pkg{chromote} to
Expand Down
17 changes: 11 additions & 6 deletions R/chromote_session.R
Original file line number Diff line number Diff line change
Expand Up @@ -559,13 +559,18 @@ ChromoteSession <- R6Class(

#' @description Summarise the current state of the object.
#' @param ... Ignored
print = function(...) {
state <- if (private$is_active_) "active" else "closed"
print = function(..., verbose = FALSE) {
if (verbose) {
cat(format(self, ...), sep = "\n")
} else {
state <- if (private$is_active_) "active" else "closed"

cat_line("<ChromoteSession> (", state, ")")
cat_line(" Session ID: ", self$get_session_id())
cat_line(" Target ID: ", self$get_target_id())
cat_line(" Parent PID: ", self$parent$get_browser()$get_process()$get_pid())
cat_line("<ChromoteSession> (", state, ")")
cat_line(" Session ID: ", self$get_session_id())
cat_line(" Target ID: ", self$get_target_id())
cat_line(" Parent PID: ", self$parent$get_browser()$get_process()$get_pid())
}
invisible(self)
},

#' @field parent [`Chromote`] object
Expand Down

0 comments on commit 3cf26cd

Please sign in to comment.