ajalt / mordant

Multiplatform text styling for Kotlin command-line applications
https://ajalt.github.io/mordant/
Apache License 2.0
935 stars 33 forks source link

Bug in Multiple Progress Bars example? #162

Closed sschuberth closed 4 months ago

sschuberth commented 4 months ago

At https://ajalt.github.io/mordant/progress/#multiple-progress-bars the example calls

val overall = progress.addTask(overallLayout, total = 100)

which does not pass any context. I guess it should be context = Unit in that case? Would it make sense to have context = Unit as a default argument for addTask()?

ajalt commented 4 months ago

The example is correct, you need to import the extension.

import com.github.ajalt.mordant.animation.progress.addTask

sschuberth commented 4 months ago

Thanks, that works. Just curious, what's the design decision to make this an extension function instead of providing context = Unit by default?

ajalt commented 4 months ago

You can't provide a default for a generic type.