Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

marcelmay/kformat

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

277 Commits
277 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.