Progress bar variables

Details

These variables can be used in cli progress bar format strings.

  • pb_bar creates a visual progress bar. If the number of total units is unknown, then it will return an empty string.

  • pb_current is the number of current progress units.

  • pb_current_bytes is the number of current progress utils formatted as bytes. The output has a constant width of six characters.

  • pb_elapsed is the elapsed time since the start of the progress bar. The time is measured since the progress bar is created with cli_progress_bar() or similar.

  • pb_elapsed_clock is the elapsed time, in hh::mm::ss format.

  • pb_elapsed_raw is the number of seconds since the start of the progress bar.

  • pb_eta is the estimated time until the end of the progress bar, in human readable form.

  • pb_eta_raw is the estimated time until the end of the progress bar, in seconds.

  • pb_eta_str is the estimated time until the end of the progress bar. It includes the "ETA:" prefix. It is only shown if the time can be estimated, otherwise it is the empty string.

  • pb_extra can be used to access extra data, see the extra argument of cli_progress_bar() and cli_progress_update().

  • pb_id is the id of the progress bar. The id has the format cli-<pid>-<counter> where <pid> is the process id, and <counter> is an integer counter that is incremented every time cli needs a new unique id.

  • pb_name is 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.

  • pb_percent is 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 " NA%".

  • pb_pid is the integer process id of the progress bar.

  • pb_rate is the progress rate, in number of units per second, formatted in a string.

  • pb_rate_raw is the raw progress rate, in number of units per second.

  • pb_rate_bytes is the progress rate, formatted as bytes per second, in human readable form.

  • pb_spin is a spinner. The default spinner is selected via a get_spinner() call.

  • pb_status is the status string of the progress bar. By default this is an empty string, but it is possible to set it in cli_progress_bar() and `cli_progress_update()].

  • pb_timestamp is a time stamp in ISO 8601 format.

  • pb_total is the total number of progress units, or NA if the number of units is unknown.

  • pb_total_bytes is the total number of progress units, formatted as bytes, in a human readable format.

Examples

# pb_bar and pb_percent cli_progress_demo( format = "Progress bar: {cli::pb_bar} {cli::pb_percent}", total = 100 )
#> Progress bar: ■■■■■■■■■■■■■■■■ 50%
# pb_current and pb_total cli_progress_demo( format = "[{cli::pb_current}/{cli::pb_total}]", total = 248 )
#> [50/248]
# pb_current_bytes, pb_total_bytes cli_progress_demo( format = "[{cli::pb_current_bytes}/{cli::pb_total_bytes}]", total = 102800, at = seq(0, 102800, by = 1024) )
#> [0.0 kB/103 kB] #> [1.0 kB/103 kB] #> [2.0 kB/103 kB] #> [3.1 kB/103 kB] #> [4.1 kB/103 kB] #> [5.1 kB/103 kB] #> [6.1 kB/103 kB] #> [7.2 kB/103 kB] #> [8.2 kB/103 kB] #> [9.2 kB/103 kB] #> [ 10 kB/103 kB] #> [ 11 kB/103 kB] #> [ 12 kB/103 kB] #> [ 13 kB/103 kB] #> [ 14 kB/103 kB] #> [ 15 kB/103 kB] #> [ 16 kB/103 kB] #> [ 17 kB/103 kB] #> [ 18 kB/103 kB] #> [ 19 kB/103 kB] #> [ 20 kB/103 kB] #> [ 22 kB/103 kB] #> [ 23 kB/103 kB] #> [ 24 kB/103 kB] #> [ 25 kB/103 kB] #> [ 26 kB/103 kB] #> [ 27 kB/103 kB] #> [ 28 kB/103 kB] #> [ 29 kB/103 kB] #> [ 30 kB/103 kB] #> [ 31 kB/103 kB] #> [ 32 kB/103 kB] #> [ 33 kB/103 kB] #> [ 34 kB/103 kB] #> [ 35 kB/103 kB] #> [ 36 kB/103 kB] #> [ 37 kB/103 kB] #> [ 38 kB/103 kB] #> [ 39 kB/103 kB] #> [ 40 kB/103 kB] #> [ 41 kB/103 kB] #> [ 42 kB/103 kB] #> [ 43 kB/103 kB] #> [ 44 kB/103 kB] #> [ 45 kB/103 kB] #> [ 46 kB/103 kB] #> [ 47 kB/103 kB] #> [ 48 kB/103 kB] #> [ 49 kB/103 kB] #> [ 50 kB/103 kB] #> [ 51 kB/103 kB] #> [ 52 kB/103 kB] #> [ 53 kB/103 kB] #> [ 54 kB/103 kB] #> [ 55 kB/103 kB] #> [ 56 kB/103 kB] #> [ 57 kB/103 kB] #> [ 58 kB/103 kB] #> [ 59 kB/103 kB] #> [ 60 kB/103 kB] #> [ 61 kB/103 kB] #> [ 62 kB/103 kB] #> [ 63 kB/103 kB] #> [ 65 kB/103 kB] #> [ 66 kB/103 kB] #> [ 67 kB/103 kB] #> [ 68 kB/103 kB] #> [ 69 kB/103 kB] #> [ 70 kB/103 kB] #> [ 71 kB/103 kB] #> [ 72 kB/103 kB] #> [ 73 kB/103 kB] #> [ 74 kB/103 kB] #> [ 75 kB/103 kB] #> [ 76 kB/103 kB] #> [ 77 kB/103 kB] #> [ 78 kB/103 kB] #> [ 79 kB/103 kB] #> [ 80 kB/103 kB] #> [ 81 kB/103 kB] #> [ 82 kB/103 kB] #> [ 83 kB/103 kB] #> [ 84 kB/103 kB] #> [ 85 kB/103 kB] #> [ 86 kB/103 kB] #> [ 87 kB/103 kB] #> [ 88 kB/103 kB] #> [ 89 kB/103 kB] #> [ 90 kB/103 kB] #> [ 91 kB/103 kB] #> [ 92 kB/103 kB] #> [ 93 kB/103 kB] #> [ 94 kB/103 kB] #> [ 95 kB/103 kB] #> [ 96 kB/103 kB] #> [ 97 kB/103 kB] #> [ 98 kB/103 kB] #> [ 99 kB/103 kB] #> [100 kB/103 kB] #> [101 kB/103 kB] #> [102 kB/103 kB]