Skip to content

Commit

Permalink
refactor(cli): Avoid the need to determine the ORT logo width
Browse files Browse the repository at this point in the history
Use a new more flexible column width option, see [1].

[1]: ajalt/mordant#109 (comment)

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Oct 4, 2023
1 parent 55a895e commit c828666
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cli/src/main/kotlin/OrtMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ private val ORT_LOGO = """
\________/ |____|___/ |____|
""".trimIndent()

private val ORT_LOGO_WIDTH = ORT_LOGO.lines().maxOf { it.length }
// A priority value that is higher than any Clikt built-in value for allocating width.
private const val HIGHEST_PRIORITY_FOR_WIDTH = 100

class OrtMain : CliktCommand(
name = ORT_NAME,
Expand Down Expand Up @@ -171,7 +172,10 @@ class OrtMain : CliktCommand(

private fun getOrtHeader(version: String): Widget =
grid {
column(0) { width = ColumnWidth.Fixed(ORT_LOGO_WIDTH) }
column(0) {
width = ColumnWidth.Custom(width = null, expandWeight = null, priority = HIGHEST_PRIORITY_FOR_WIDTH)
}

column(1) { verticalAlign = VerticalAlign.BOTTOM }
padding { bottom = 1 }

Expand Down

0 comments on commit c828666

Please sign in to comment.