How to update the Progress bar in cli with purrr?

Hi I would like to update the cli bar within purrr function to include the name of

a <- LETTERS
walk(a, function(x){Sys.sleep(2)}, .progress = list(
  type = "iterator", 
  format = "Processing {cli::pb_percent}",
  clear = FALSE))

to get

Processing A 4%
Processing B 8%
etc

library(purrr)
a <- LETTERS
walk(a, function(x){Sys.sleep(.2)}, .progress = list(
  type = "iterator", 
  format = "Processing {a[{cli::pb_current}]} {cli::pb_percent}",
  clear = FALSE))
1 Like

What is the different between using [{}] and {} in the code abode??? and what if I would like to add new line "\n" before Processing?

The second set of {} is not actually needed:

library(purrr)
a <- LETTERS
walk(a, function(x){Sys.sleep(.2)}, .progress = list(
  type = "iterator", 
  format = "Processing {a[cli::pb_current]} {cli::pb_percent}",
  clear = FALSE))