Skip to content

Better progress report #3448

@Yamakaky

Description

@Yamakaky

Currently, cargo only outputs "Compiling xxx" when starting a job. I propose using ANSI control sequences to have a more finer progress report while keeping the same number of line output.
PoC with jobs in WiP or done state:

#!/usr/bin/env bash

a=(10 4 3 2 5 7 8 1 6 9)

for i in $(seq 1 10); do
    echo "doing $i"
done

for i in $(seq 1 10); do
    # \033[nA moves the cursor up n lines
    printf "\033[$((11 - i))A"
    # Print done jobs. \033[K clears the current line
    printf "\033[Kdone $i\n"
    # Print jobs still running
    for x in "${a[@]}"; do
        if [[ $x -gt $i ]]; then
            printf "\033[Kdoing $x\n"
        fi
    done
    sleep 1
done

The basic idea is with n jobs running, when a job finishes we erase the n previous lines, print the finished jobs then print the jobs still working.
When this setup is working, we can expand it to show a more finer progress report for each job.
Windows seems to support it, MacOS and Linux does.
See #833, maybe also others.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-console-outputArea: Terminal output, colors, progress bar, etc.C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions