GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — cli/man/cli_progress_step.Rd at main · multimeric/cli Expand file tree/ Copy pathcli_progress_step.RdMore file actions 144 lines (122 loc) · 4.16 KB / Copy pathcli_progress_step.RdFile metadata and controls144 lines (122 loc) · 4.16 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 % Generated by roxygen2: do not edit by hand % Please edit documentation in R/progress-client.R \name{cli_progress_step} \alias{cli_progress_step} \title{Simplified cli progress messages, with styling} \usage{ cli_progress_step( msg, msg_done = msg, msg_failed = msg, spinner = FALSE, class = if (!spinner) ".alert-info", current = TRUE, .auto_close = TRUE, .envir = parent.frame(), ... ) } \arguments{ \item{msg}{Message to show. It may contain glue substitution and cli styling. It can be updated via \code{\link[=cli_progress_update]{cli_progress_update()}}, as usual. It is style as a cli info alert (see \code{\link[=cli_alert_info]{cli_alert_info()}}).} \item{msg_done}{Message to show on successful termination. By default this it is the same as \code{msg} and it is styled as a cli success alert (see \code{\link[=cli_alert_success]{cli_alert_success()}}).} \item{msg_failed}{Message to show on unsuccessful termination. By default it is the same as \code{msg} and it is styled as a cli danger alert (see \code{\link[=cli_alert_danger]{cli_alert_danger()}}).} \item{spinner}{Whether to show a spinner at the beginning of the line. To make the spinner spin, you'll need to call \code{cli_progress_update()} regularly.} \item{class}{cli class to add to the message. By default there is no class for steps with a spinner.} \item{current}{Passed to \code{\link[=cli_progress_bar]{cli_progress_bar()}}.} \item{.auto_close}{Passed to \code{\link[=cli_progress_bar]{cli_progress_bar()}}.} \item{.envir}{Passed to \code{\link[=cli_progress_bar]{cli_progress_bar()}}.} \item{...}{Passed to \code{\link[=cli_progress_bar]{cli_progress_bar()}}.} } \description{ This is a simplified progress bar, a single (dynamic) message, without progress units. } \details{ \code{cli_progress_step()} always shows the progress message, even if no update is due. \subsection{Basic use}{ \if{html}{\out{<div class="sourceCode r">}}\preformatted{f <- function() \{ cli_progress_step("Downloading data") Sys.sleep(2) cli_progress_step("Importing data") Sys.sleep(1) cli_progress_step("Cleaning data") Sys.sleep(2) cli_progress_step("Fitting model") Sys.sleep(3) \} f() }\if{html}{\out{</div>}} \if{html}{\figure{progress-step.svg}} } \subsection{Spinner}{ You can add a spinner to some or all steps with \code{spinner = TRUE}, but not that this will only work if you call \code{\link[=cli_progress_update]{cli_progress_update()}} regularly. \if{html}{\out{<div class="sourceCode r">}}\preformatted{f <- function() \{ cli_progress_step("Downloading data", spinner = TRUE) for (i in 1:100) \{ Sys.sleep(2/100); cli_progress_update() \} cli_progress_step("Importing data") Sys.sleep(1) cli_progress_step("Cleaning data") Sys.sleep(2) cli_progress_step("Fitting model", spinner = TRUE) for (i in 1:100) \{ Sys.sleep(3/100); cli_progress_update() \} \} f() }\if{html}{\out{</div>}} \if{html}{\figure{progress-step-spin.svg}} } \subsection{Dynamic messages}{ You can make the step messages dynamic, using glue templates. Since \code{cli_progress_step()} show that message immediately, we need to initialize \code{msg} first. \if{html}{\out{<div class="sourceCode r">}}\preformatted{f <- function() \{ msg <- "" cli_progress_step("Downloading data\{msg\}", spinner = TRUE) for (i in 1:100) \{ Sys.sleep(2/100) msg <- glue::glue(", got file \{i\}/100") cli_progress_update() \} cli_progress_step("Importing data") Sys.sleep(1) cli_progress_step("Cleaning data") Sys.sleep(2) cli_progress_step("Fitting model", spinner = TRUE) for (i in 1:100) \{ Sys.sleep(3/100); cli_progress_update() \} \} f() }\if{html}{\out{</div>}} \if{html}{\figure{progress-step-dynamic.svg}} } \subsection{Termination messages}{ You can specify a different message for successful and/or unsuccessful termination: \if{html}{\out{<div class="sourceCode r">}}\preformatted{f <- function() \{ size <- 0L cli_progress_step( "Downloading data.", msg_done = "Downloaded \{prettyunits::pretty_bytes(size)\}.", spinner = TRUE ) for (i in 1:100) \{ Sys.sleep(3/100) size <- size + 8192 cli_progress_update() \} \} f() }\if{html}{\out{</div>}} \if{html}{\figure{progress-step-msg.svg}} } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |