console-rs / indicatif

A command line progress reporting library for Rust
MIT License
4.23k stars 240 forks source link

Modify progress style based on position #490

Open akashlama1998-icloud opened 1 year ago

akashlama1998-icloud commented 1 year ago

Modify progress style based on position

I'm looking for a way to modify progress style based on its index position. Particularly, I need a way to determine if the progress is the last item, so that I can use └─ instead of ├─ for last item.

Current Behavior

┌ [1/?] 📥 Downloading files
│ ⠋ Downloading files 245/856 (46%) eta 00:01:23
│ ├─ ⠹ Downloading file "file-1.ext" 450 KiB/s (64%) eta 5s
│ ├─ ⠼ Downloading file "file-2.ext" 260 KiB/s (12%) eta 1s
│ ├─ ⠦ Downloading file "file-3.ext" 320 KiB/s (47%) eta 3s
│ ├─ ⠇ Downloading file "file-4.ext" 120 KiB/s (71%) eta 8s

Expected Behavior

┌ [1/?] 📥 Downloading files
│ ⠋ Downloading files 245/856 (46%) eta 00:01:23
│ ├─ ⠹ Downloading file "file-1.ext" 450 KiB/s (64%) eta 5s
│ ├─ ⠼ Downloading file "file-2.ext" 260 KiB/s (12%) eta 1s
│ ├─ ⠦ Downloading file "file-3.ext" 320 KiB/s (47%) eta 3s
│ └─ ⠇ Downloading file "file-4.ext" 120 KiB/s (71%) eta 8s
djc commented 1 year ago

I suppose that makes sense. I don't think there are any facilities for this now, would you be interested in submitting a PR to add some? I'm honestly not sure how this would fit in to the existing template system. I'm guessing this should be a custom ProgressTracker and then we make sure the ProgressState exposes enough state for you to draw the right symbol?

@chris-laplante this sounds like something you might be interested in as well?

chris-laplante commented 1 year ago

Yeah, that does sound interesting. I'm also not sure how to implement it though.