Skip to content

Documenting progress bar pattern with completion message #610

Open
@Shians

Description

@Shians

Just want to put this here and maybe convince you to document the pattern in some form under cli_progress_bar(). I wanted the progress bar to leave a message and print the elapsed time after it completed. The existing API allowed this but it was not obvious how to accomplish it and copy the existing style of cli_progress_step().

cli::cli_progress_bar(
        "Processing",
        total = 100,
        format_done = "{.alert-success Processing completed {.timestamp {cli::pb_elapsed}}}",
        format_failed = "{.alert-danger Processing failed {.timestamp {cli::pb_elapsed}}}",
        clear = FALSE
)

for (i in 1:100) {
    Sys.sleep(3/100)
    cli::cli_progress_update()
}
#> Processing ■■■■■■■■■                         27% | ETA:  3s
#> Processing ■■■■■■■■■■■■■■■■■■                56% | ETA:  2s
#> ✔ Processing completed [3.5s]
#> 

Created on 2023-06-02 with reprex v2.0.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions