GithubHelp home page GithubHelp logo

semihbkgr / aligntable Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 273 KB

simplifies data visualization in the console environment, making it effortless to present data through aligned tables and hierarchical trees

License: MIT License

Go 100.00%
cli console golang table tree

aligntable's Introduction

aligntable

aligntable simplifies data visualization in the console environment, making it effortless to present data legibly and aesthetically through well-aligned tables and hierarchical trees.

$ go get github.com/semihbkgr/[email protected]

Usage

To get started with aligntable, refer to the examples in the _examples directory. These examples showcase how to create aligned tables and hierarchical trees, providing insight into the capabilities of the library.

Console Output

Check out the screenshot below to see the console output generated by the example:

console output

Table

It is the example of how to print data in table form

t := aligntable.New()
t.Rows = []*aligntable.Row{
    {
        Cells: []*aligntable.Cell{
            {Text: "NAME"},
            {Text: "AGE"},
            {Text: "CITY"},
        },
    },
}

for _, entry := range unmarshalTableData() {
    t.Rows = append(t.Rows, &aligntable.Row{
        Cells: []*aligntable.Cell{
            {Text: entry["Name"].(string)},
            {Text: strconv.Itoa(entry["Age"].(int))},
            {Text: entry["City"].(string)},
        },
    })
}

fmt.Println(t)
NAME     AGE   CITY
Alice    28    New York
Bob      35    Los Angeles
Connor   22    Chicago
Daniel   30    Houston
Emily    29    San Francisco

Tree

It is the example of how to print data in tree form

t := aligntable.Tree{}
t.Nodes = []*aligntable.Node{
    {
        Text: "Fruits",
        SubNodes: []*aligntable.Node{
            {
                Text: "Citrus",
                SubNodes: []*aligntable.Node{
                    {Text: "Orange"},
                    {Text: "Lemon"},
                    {Text: "Lime"},
                },
            },
            {
                Text: "Berries",
                SubNodes: []*aligntable.Node{
                    {Text: "Strawberry"},
                    {Text: "Lemon"},
                    {Text: "Blueberry"},
                },
            }, 
...
Fruits
├───────── Citrus
│          ├────────────── Orange
│          ├────────────── Lemon
│          └────────────── Lime
├───────── Berries
│          ├────────────── Strawberry
│          ├────────────── Lemon
│          └────────────── Blueberry
└───────── Tropical
           ├────────────── Mango
           ├────────────── Pineapple
           └────────────── Blueberry
Vegetables
├───────── Leafy Greens
│          ├────────────── Lettuce
│          └────────────── Spinach
└───────── Root Vegetables
           ├────────────── Carrot
           ├────────────── Potato
           └────────────── Beetroot

aligntable's People

Contributors

semihbkgr avatar

Watchers

 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.