Skip to content

Commit

Permalink
Omit ANSI in as.character() methods
Browse files Browse the repository at this point in the history
So copying to clipboard with
```
clipr::write_clip(session_info())
```
does not have ANSI sequences.
  • Loading branch information
gaborcsardi committed Oct 13, 2021
1 parent 4602eb2 commit 4cfab6e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions R/external-info.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,7 @@ print.external_info <- function(x, ...) {
#' @export

as.character.external_info <- function(x, ...) {
old <- options(cli.num_colors = 1)
on.exit(options(old), add = TRUE)
format(x, ...)
}
2 changes: 2 additions & 0 deletions R/package-info.R
Original file line number Diff line number Diff line change
Expand Up @@ -322,5 +322,7 @@ print.packages_info <- function(x, ...) {
#' @export

as.character.packages_info <- function(x, ...) {
old <- options(cli.num_colors = 1)
on.exit(options(old), add = TRUE)
format(x, ...)
}
2 changes: 2 additions & 0 deletions R/platform-info.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ print.platform_info <- function(x, ...) {
#' @export

as.character.platform_info <- function(x, ...) {
old <- options(cli.num_colors = 1)
on.exit(options(old), add = TRUE)
format(x, ...)
}

Expand Down
2 changes: 2 additions & 0 deletions R/python-info.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ format.python_info <- function(x, ...) {
#' @export

as.character.python_info <- function(x, ...) {
old <- options(cli.num_colors = 1)
on.exit(options(old), add = TRUE)
format(x, ...)
}

Expand Down
2 changes: 2 additions & 0 deletions R/session-info.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ format.session_info <- function(x, ...) {
#' @export

as.character.session_info <- function(x, ...) {
old <- options(cli.num_colors = 1)
on.exit(options(old), add = TRUE)
format(x, ...)
}

Expand Down

0 comments on commit 4cfab6e

Please sign in to comment.