Skip to content

KFormat is a tiny Kotlin library for formatted text output such as printing values in a structured table

License

Notifications You must be signed in to change notification settings

marcelmay/kformat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KFormat

Maven Central License Pure Java + Kotlin CI

KFormat is a tiny Kotlin library for formatted text output such as printing values in a structured table. Typical use cases include CLI tool development.

  • Table (doc/source)
    • Grid-based like an HTML table
    • Auto-sizing of cell widths
    • Formatting hints, such as for alignment, floating precision rendering or border rendering

Examples

Format a table including cell resizing:

table {
    header("A", "B", "C", "Long_Header")

    row(10, "b...1", 2.1f, "foo")
    row(20, "b2", 1/3f, "bar")

    hints {
        alignment("A", Hints.Alignment.LEFT)
        precision("C", 2)
        postfix("C", "%")
        borderStyle = Table.BorderStyle.SINGLE_LINE // or NONE
    }
}.render(StringBuilder())

Generated output:

A  |     B |     C | Long_Header
---|-------|-------|------------
10 | b...1 | 2.10% |         foo
20 |    b2 | 0.33% |         bar

For further examples, see test cases

Downloading

Download from Maven Central or use GAV de.m3y.kformat:kformat:VERSION

<dependency>
    <groupId>de.m3y.kformat</groupId>
    <artifactId>kformat</artifactId>
    <version>VERSION</version>
</dependency>

Building

mvn install
mvn dokka:dokka -Pgithub-pages # Re-generates docs/dokka/ markdown documentation

Copyright

Copyright 2019-2025 Marcel May

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy