> For the complete documentation index, see [llms.txt](https://commandbox.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://commandbox.ortusbooks.com/5.0.0/task-runners/progress-bar.md).

# Progress Bar

When writing a Task that needs to iterate some predefined amount of work that might take some time, you can now tap into the Progress Bars in CommandBox easily for your own purposes.

There are two different progress bars in CommandBox.  One specifically for downloading files, and a generic one.

## Progressable Downloader

Here is how you can download a file in a Task Runner and have a progress bar animation that contains all the usual data such as download speed and file size.  The progressable downloader will automatically take any HTTP proxy settings into account.

![](https://3591006956-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA-UVvV3_TgzQyCXMWK%2F-LJqkgVkgGKH6jzjAWle%2F-LJqmUntaqD34N2yZ8nC%2Fimage.png?alt=media\&token=54f8d3e5-19d8-4c15-b357-227212c2bcf6)

Full docs for the Progressable Downloader are [here](/5.0.0/task-runners/downloading-files.md).

## Generic Progress Bar

You can also use a generic progress bar for any purpose.  It is up to you to update the progress bar with the current percentage.  If you are inside of an Interactive Job, the progress bar will automatically show at the bottom of the job output.

![](https://3591006956-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA-UVvV3_TgzQyCXMWK%2F-LJqkgVkgGKH6jzjAWle%2F-LJql1P9Axv4DuByPdOe%2Fimage.png?alt=media\&token=e01754ea-a6db-45e6-9451-00bb277c82bd)

```javascript
component {
	property name="progressBarGeneric" inject="progressBarGeneric";
	
	function run() {
	    // Draw initial progress bar
		progressBarGeneric.update( percent=0 );
		
		// Update as we progress
		sleep( 1000 );
		progressBarGeneric.update( percent=25, currentCount=250, totalCount=1000 );
		sleep( 1000 );
		progressBarGeneric.update( percent=50, currentCount=500, totalCount=1000 );
		sleep( 1000 );
		progressBarGeneric.update( percent=75, currentCount=750, totalCount=1000 );
		sleep( 1000 );
		// Progress bar automaticaly hides once it reaches 100%
		progressBarGeneric.update( percent=100, currentCount=1000, totalCount=1000 );
	}
}
```

The `currentCount` and `totalCount` parameters to the `update()` method are optional.  They will show in the output only if you provide them. &#x20;

### Other Methods

You can remove the progress bar from the screen at any time with `clear()`.

```javascript
progressBarGeneric.clear();
```

You can show the bar again at any percentage simply by calling the `update()` method.  No need to initialize anything.  The progress bar object carries no state.

```javascript
progressBarGeneric.update( percent=27 );
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://commandbox.ortusbooks.com/5.0.0/task-runners/progress-bar.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
