Skip to content

Commit

Permalink
Only print non null parts of message objects
Browse files Browse the repository at this point in the history
Fixes #88
  • Loading branch information
jimhester committed Aug 13, 2019
1 parent 9664f00 commit ae319b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Expand Up @@ -3,6 +3,9 @@
* The authentication has been completely redone to utilize the
[gargle](https://cran.r-project.org/package=gargle) package.

* `print.gmail_message()` now only prints the parts of the message that are
defined (#88)

# gmailr 0.7.1

* Bundle a application token and secret in gmailr so the average user won't need to create an application.
Expand Down
13 changes: 8 additions & 5 deletions R/gmailr.R
Expand Up @@ -203,13 +203,16 @@ print.gmail_message <- function(x, ...){
date <- date(x)
subject <- subject(x)
id <- id(x)
body <- body(x, collapse = TRUE)
cat(p(
c(
crayon::bold("Id: "), id, "\n",
crayon::bold("To: "), to, "\n",
crayon::bold("From: "), from, "\n",
crayon::bold("Date: "), date, "\n",
crayon::bold("Subject: "), subject, "\n",
body(x, collapse = TRUE)), "\n")
if (!is.null(to)) { c(crayon::bold("To: "), to, "\n") },
if (!is.null(from)) c(crayon::bold("From: "), from, "\n"),
if (!is.null(date)) c(crayon::bold("Date: "), date, "\n"),
if (!is.null(subject)) c(crayon::bold("Subject: "), subject, "\n"),
if (!is.null(body)) c(body)
)))
}

#' @export
Expand Down

0 comments on commit ae319b5

Please sign in to comment.