diff --git a/src/ProgressLogging.jl b/src/ProgressLogging.jl index 821023c..7d8c9dd 100644 --- a/src/ProgressLogging.jl +++ b/src/ProgressLogging.jl @@ -164,13 +164,23 @@ function asprogress( progress = undef, # `undef` is an arbitrary unsupported value kwargs..., ) + if hasfield(typeof(name), :progress) && is_progresslike(name.progress) + return _asprogress(name.progress) + end if progress isa Union{Nothing,Real,AbstractString} return _asprogress(name, id; progress = progress, kwargs...) else + if is_progresslike(progress) + return _asprogress(progress) + end return nothing end end +is_progresslike(_::T) where {T} = all(in.(fieldnames(Progress), Ref(fieldnames(T)))) + +_asprogress(progress) = Progress((getfield(progress, f) for f in fieldnames(Progress))...) + # `parentid` is used from `@logprogress`. function _asprogress(name, id, parentid = ROOTID; progress, _...) if progress isa Union{Nothing,Real}