Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status display #24

Closed
hadley opened this issue Oct 26, 2017 · 3 comments
Closed

Status display #24

hadley opened this issue Oct 26, 2017 · 3 comments

Comments

@hadley
Copy link
Member

hadley commented Oct 26, 2017

Inspired by https://github.com/MichaelCereda/pretty-cli#readme and @gaborcsardi's idea for testthat output

cat_status <- function(status, details, info = NULL,
                       status_col = NULL,
                       details_col = status_col) {

  status <- apply_style(paste0(" ", status, " "), status_col, bg = TRUE)
  width <- ansistrings::ansi_nchar(status, type = "width") + 1

  details <- apply_style(str_indent(details, 0, width), details_col)

  cat_line(status, " ", details)
  if (!is.null(info)) {
    cat_line(str_indent(info, width, width))
  }

  invisible()

}

str_indent <- function(x, indent = 0, exdent = indent) {
  if (indent > 0) {
    indent <- paste0(rep(" ", indent), collapse = "")
    x <- gsub("^", indent, x)
  }

  if (exdent > 0) {
    indent <- paste0("\n", paste0(rep(" ", exdent), collapse = ""))
    x <- gsub("\\n", indent, x)
  }

  x
}
  • Should also autowrap text. Give paragraphs as vector?
  • Should also pick text colour automatically - convert colour to rgb, then to hcl, then switch based on luminance
@gaborcsardi
Copy link
Member

I think we can leave this to the next version of cli.

@hadley
Copy link
Member Author

hadley commented Nov 3, 2017

Agreed

@gaborcsardi
Copy link
Member

Closing in favour of #37.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants