Progress monitor with notify syntax

I am exploring the addition of a progress meter for AppBundler.jl and am looking into a minimally invasive method. I would like a progress meter that displays all steps in advance, shows a running timer or time indicators, and uses colour changes for completed, active, and remaining tasks. I would like to drive it with a notify API something like:

@enum ProcessStep Loading Processing Validating

const STEP_MESSAGES = Dict(
    Loading => "Loading data",
    Processing => "Processing data",
    Validating => "Validating results",
)

function multistep_process(data; progress::Condition=monitor([Loading, Processing, Validating]))
    sleep(0.5)
    notify(progress, Loading)
    sleep(0.5)
    notify(progress, Processing)
    sleep(0.5)
    notify(progress, Validating)
    return data .^ 2
end

As a first approximation Claude gave me:

function monitor(steps::Vector{ProcessStep})
    cond = Condition()
    @async begin
        println("\nProgress:")
        for step in steps
            println("[ ] $(STEP_MESSAGES[step])")
        end
        print("\e[$(length(steps))A")
        notify(cond)
        
        for step in steps
            wait(cond)
            println("[●] $(STEP_MESSAGES[step])\e[K")
        end
    end
    wait(cond)
    return cond
end

But now I want to make it pretty. What are my options here?

1 Like