Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 

README.md

KFormat

Maven Central License Pure Java + Kotlin

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 a 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 dokka:dokka

Copyright

Copyright 2019-2020 Marcel May

About

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

Topics

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.