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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/progress-variables.R
\name{progress-variables}
\alias{progress-variables}
\alias{cli__pb_bar}
\alias{pb_bar}
\alias{cli__pb_current}
\alias{pb_current}
\alias{cli__pb_current_bytes}
\alias{pb_current_bytes}
\alias{cli__pb_elapsed}
\alias{pb_elapsed}
\alias{cli__pb_elapsed_clock}
\alias{pb_elapsed_clock}
\alias{cli__pb_elapsed_raw}
\alias{pb_elapsed_raw}
\alias{cli__pb_eta}
\alias{pb_eta}
\alias{cli__pb_eta_raw}
\alias{pb_eta_raw}
\alias{cli__pb_eta_str}
\alias{pb_eta_str}
\alias{cli__pb_extra}
\alias{pb_extra}
\alias{cli__pb_id}
\alias{pb_id}
\alias{cli__pb_name}
\alias{pb_name}
\alias{cli__pb_percent}
\alias{pb_percent}
\alias{cli__pb_pid}
\alias{pb_pid}
\alias{cli__pb_rate}
\alias{pb_rate}
\alias{cli__pb_rate_raw}
\alias{pb_rate_raw}
\alias{cli__pb_rate_bytes}
\alias{pb_rate_bytes}
\alias{cli__pb_spin}
\alias{pb_spin}
\alias{cli__pb_status}
\alias{pb_status}
\alias{cli__pb_timestamp}
\alias{pb_timestamp}
\alias{cli__pb_total}
\alias{pb_total}
\alias{cli__pb_total_bytes}
\alias{pb_total_bytes}
\title{Progress bar variables}
\description{
Progress bar variables
}
\details{
These variables can be used in cli progress bar format
strings. They are calculated on demand. To use a variable, e.g. \code{pb_bar}
in a package, you either need to to import \code{pb_bar} from cli, or use
the qualified form in the format string: \code{cli::pb_bar}.
Similarly, in R scripts, you can use \code{pb_bar} after \code{library(cli)},
or \code{cli::pb_bar} if you do not attach the cli package.
\subsection{\code{pb_bar}}{
Creates a visual progress bar. If the number of total units
is unknown, then it will return an empty string.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
total = 100,
format = "Fitting model \{cli::pb_bar\} \{cli::pb_percent\}"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> Fitting model <span style="color: #859900;">█████████████████████</span><span style="color: #002B36;">██████████</span><span style="color: #859900;"> </span> 66%
</pre></div>
}}
}
\subsection{\code{pb_current}}{
The number of current progress units.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_spin\} Reading file \{cli::pb_current\}/\{cli::pb_total\}"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> ⠙ Reading file 66/100
</pre></div>
}}
}
\subsection{\code{pb_current_bytes}}{
The number of current progress units formatted as bytes.
The output has a constant width of six characters.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
format = "Got \{cli::pb_current_bytes\} in \{cli::pb_elapsed\}"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> Got 524 kB in 5s
</pre></div>
}}
}
\subsection{\code{pb_elapsed}}{
The elapsed time since the start of the progress bar. The time is
measured since the progress bar was created with \code{\link[=cli_progress_bar]{cli_progress_bar()}}
or similar.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_bar\} \{cli::pb_percent\} [\{cli::pb_elapsed\}]"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> <span style="color: #859900;">█████████████████████</span><span style="color: #002B36;">██████████</span><span style="color: #859900;"> </span> 66% [5s]
</pre></div>
}}
}
\subsection{\code{pb_elapsed_clock}}{
The elapsed time, in \verb{hh::mm::ss} format.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_bar\} \{cli::pb_percent\} [\{cli::pb_elapsed_clock\}]"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> <span style="color: #859900;">█████████████████████</span><span style="color: #002B36;">██████████</span><span style="color: #859900;"> </span> 66% [00:00:05]
</pre></div>
}}
}
\subsection{\code{pb_elapsed_raw}}{
The number of seconds since the start of the progress bar.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_bar\} \{cli::pb_percent\} [\{round(cli::pb_elapsed_raw)\}s]"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> <span style="color: #859900;">█████████████████████</span><span style="color: #002B36;">██████████</span><span style="color: #859900;"> </span> 66% [5s]
</pre></div>
}}
}
\subsection{\code{pb_eta}}{
The estimated time until the end of the progress bar,
in human readable form.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_bar\} \{cli::pb_percent\} | ETA: \{cli::pb_eta\}"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> <span style="color: #859900;">█████████████████████</span><span style="color: #002B36;">██████████</span><span style="color: #859900;"> </span> 66% | ETA: 3s
</pre></div>
}}
}
\subsection{\code{pb_eta_raw}}{
The estimated time until the end of the progress
bar, in seconds. This is useful if you want to adjust the default
\code{pb_eta} display.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_bar\} \{cli::pb_percent\} | ETA: \{round(cli::pb_eta_raw)\}s"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> <span style="color: #859900;">█████████████████████</span><span style="color: #002B36;">██████████</span><span style="color: #859900;"> </span> 66% | ETA: 3s
</pre></div>
}}
}
\subsection{\code{pb_eta_str}}{
The estimated time until the end of the progress bar.
It includes the \code{"ETA:"} prefix. It is only shown if the time can be
estimated, otherwise it is the empty string.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_bar\} \{cli::pb_percent\} | \{cli::pb_eta_str\}"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> <span style="color: #859900;">█████████████████████</span><span style="color: #002B36;">██████████</span><span style="color: #859900;"> </span> 66% | ETA: 3s
</pre></div>
}}
}
\subsection{\code{pb_extra}}{
\code{pb_extra} can be used to access extra data, see the \code{extra} argument
of \code{cli_progress_bar()} and \code{cli_progress_update()}.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
total = 100,
extra = list(user = whoami::username()),
format = "Cleaning cache for user '\{cli::pb_extra$user\}': \{cli::pb_current_bytes\}"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> Cleaning cache for user 'gaborcsardi': 161 MB
</pre></div>
}}
}
\subsection{\code{pb_id}}{
The id of the progress bar. The id has the format
\verb{cli-<pid>-<counter>} where \verb{<pid>} is the process id, and
\verb{<counter>} is an integer counter that is incremented every time
cli needs a new unique id.
This is useful for debugging progress bars.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
format = "Progress bar '\{cli::pb_id\}' is at \{cli::pb_current\}"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> Progress bar 'cli-82040-1814' is at 64
</pre></div>
}}
}
\subsection{\code{pb_name}}{
The name of the progress bar. This is supplied by the
developer, and it is by default the empty string. A space character
is added to non-empty names.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
name = "Loading training data",
total = 100,
format = "\{cli::pb_name\} \{cli::pb_bar\} \{cli::pb_percent\}"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> Loading training data <span style="color: #859900;">█████████████████████</span><span style="color: #002B36;">██████████</span><span style="color: #859900;"> </span> 66%
</pre></div>
}}
}
\subsection{\code{pb_percent}}{
The percentage of the progress bar, always formatted
in three characters plus the percentage sign. If the total number of
units is unknown, then it is \code{" NA\%"}.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_bar\} \{cli::pb_percent\}"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> <span style="color: #859900;">█████████████████████</span><span style="color: #002B36;">██████████</span><span style="color: #859900;"> </span> 66%
</pre></div>
}}
}
\subsection{\code{pb_pid}}{
The integer process id of the progress bar. This is useful if you are
aggregating logging output or progress results from multiple processes.
}
\subsection{\code{pb_rate}}{
The progress rate, in number of units per second, formatted in a string.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
total = 156,
format = "Reading input files \{pb_current\}/\{pb_total\} [\{pb_rate\}]"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> Reading input files 68/156 [14/s]
</pre></div>
}}
}
\subsection{\code{pb_rate_raw}}{
The raw progress rate, in number of units per second.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
total = 156,
format = "Reading input files \{pb_current\}/\{pb_total\} [\{round(pb_rate_raw)\}/s]"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> Reading input files 68/156 [14/s]
</pre></div>
}}
}
\subsection{\code{pb_rate_bytes}}{
The progress rate, formatted as bytes per second, in human readable form.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
total = 256 * 1024 * 1014,
format = paste0(
"Reading data \{pb_current_bytes\}/\{pb_total_bytes\} ",
"[\{ansi_trimws(pb_rate_bytes)\}]"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> Reading data 70 MB/266 MB [14 MB/s]
</pre></div>
}}
}
\subsection{\code{pb_spin}}{
A spinner. The default spinner is selected via a \code{\link[=get_spinner]{get_spinner()}} call.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_spin\} Reading file \{cli::pb_current\}/\{cli::pb_total\}"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> ⠙ Reading file 66/100
</pre></div>
}}
}
\subsection{\code{pb_status}}{
The status string of the progress bar. By default this is an empty
string, but it is possible to set it in \code{\link[=cli_progress_bar]{cli_progress_bar()}}
and `cli_progress_update()].
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(status = "Connecting...")
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> ⠙ Connecting... 0 done (0/s) | 1s
</pre></div>
}}
}
\subsection{\code{pb_timestamp}}{
A time stamp for the current time in ISO 8601 format.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
"Loading training data files",
format = "\{pb_timestamp\} \{pb_current\} (\{pb_rate\})"
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> 2022-09-07T11:27:50+00:00 125 (25/s)
</pre></div>
}}
}
\subsection{\code{pb_total}}{
The total number of progress units, or \code{NA} if the number of units is
unknown.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
total = 100,
format = "\{cli::pb_spin\} Reading file \{cli::pb_current\}/\{cli::pb_total\}"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> ⠙ Reading file 66/100
</pre></div>
}}
}
\subsection{\code{pb_total_bytes}}{
The total number of progress units, formatted as
bytes, in a human readable format.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{cli_progress_bar(
total = 256 * 1024 * 1014,
format = paste0(
"Reading data \{pb_current_bytes\}/\{pb_total_bytes\} ",
"[\{ansi_trimws(pb_rate_bytes)\}]"
)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> Reading data 70 MB/266 MB [14 MB/s]
</pre></div>
}}
}
}
\seealso{
Other progress bar functions:
\code{\link{cli_progress_along}()},
\code{\link{cli_progress_bar}()},
\code{\link{cli_progress_builtin_handlers}()},
\code{\link{cli_progress_message}()},
\code{\link{cli_progress_num}()},
\code{\link{cli_progress_output}()},
\code{\link{cli_progress_step}()},
\code{\link{cli_progress_styles}()}
}
\concept{progress bar functions}
|