Giter Site home page Giter Site logo

marklapasa / kformat Goto Github PK

View Code? Open in Web Editor NEW

This project forked from marcelmay/kformat

0.0 0.0 0.0 237 KB

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

License: Apache License 2.0

Kotlin 100.00%

kformat's Introduction

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 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
mvn dokka:dokka -Pgithub-pages

Copyright

Copyright 2019-2024 Marcel May

kformat's People

Contributors

marcelmay avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.