Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/ProgressMeter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module ProgressMeter

using Printf: @sprintf
using Distributed
import Base.show

export Progress, ProgressThresh, ProgressUnknown, BarGlyphs, next!, update!, cancel, finish!, @showprogress, progress_map, progress_pmap, ijulia_behavior

Expand Down Expand Up @@ -118,6 +119,23 @@ mutable struct Progress <: AbstractProgress
end
end

"""
Pretty print short description of Progress
"""
function Base.show(io::IO, p::Progress)
print(io, "Progress(n=$(p.n)")
if p.start != 0
print(io, ",start=$(p.start)")
end
if !isnothing(p.barlen)
print(io, ",barlen=$(p.barlen)")
end
if p.barglyphs != defaultglyphs
print(io, ",barglyphs=$(p.barglyphs)")
end
print(io, ")")
end

"""
`prog = ProgressThresh(thresh; dt=0.1, desc="Progress: ",
color=:green, output=stderr)` creates a progress meter for a task
Expand Down
15 changes: 14 additions & 1 deletion test/test_showvalues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,17 @@ for i in 1:50
sleep(0.1)
end

end # if

end # if

println("Testing Base.show for Progress")
prog = Progress(50)
io = IOBuffer()
Base.show(io, prog)
progShowStr = String(take!(io))
@test progShowStr == "Progress(n=50)"
prog = Progress(50, start=10, barlen=100)
io = IOBuffer()
Base.show(io, prog)
progShowStr = String(take!(io))
@test progShowStr == "Progress(n=50,start=10,barlen=100)"