All Projects → modood → table

modood / table

Licence: MIT license
Produces a string that represents slice data in a text table, inspired by gajus/table.

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to table

teks
Easily get custom go template based outputs to your command-line tool. Like in docker/kubernetes
Stars: ✭ 41 (-68.46%)
Mutual labels:  format, table, output
Terminaltables
Generate simple tables in terminals from a nested list of strings.
Stars: ✭ 685 (+426.92%)
Mutual labels:  ascii, table
Ascii Tables
Quickly format table in ASCII. Great for code comments, or Github Markdown!
Stars: ✭ 416 (+220%)
Mutual labels:  ascii, table
AutoFormatInputWatcher
This repository contains input watcher for auto formatting digits in edit text
Stars: ✭ 15 (-88.46%)
Mutual labels:  text, format
ctable
C library to print nicely formatted tables
Stars: ✭ 13 (-90%)
Mutual labels:  ascii, table
Libfort
C/C++ library to create formatted ASCII tables for console applications
Stars: ✭ 255 (+96.15%)
Mutual labels:  ascii, table
Markdown Table
Markdown tables, with alignment
Stars: ✭ 164 (+26.15%)
Mutual labels:  ascii, table
S2
⚡️ Practical analytical Table rendering core lib.
Stars: ✭ 818 (+529.23%)
Mutual labels:  table, sheet
Art
🎨 ASCII art library for Python
Stars: ✭ 1,026 (+689.23%)
Mutual labels:  text, ascii
Texttable
Swift package for easily rendering text tables. Inspired by the Python tabulate library.
Stars: ✭ 82 (-36.92%)
Mutual labels:  text, table
termtable
Simple and highly customizable library to display tables in the terminal.
Stars: ✭ 41 (-68.46%)
Mutual labels:  ascii, table
indicium
🔎 A simple in-memory search for collections and key-value stores.
Stars: ✭ 41 (-68.46%)
Mutual labels:  text, struct
Converter
database table to golang struct (table to struct) converter with cli and go lib support
Stars: ✭ 167 (+28.46%)
Mutual labels:  table, struct
Simpletable
Simple tables in terminal with Go
Stars: ✭ 288 (+121.54%)
Mutual labels:  ascii, table
React Datasheet
Excel-like data grid (table) component for React
Stars: ✭ 4,866 (+3643.08%)
Mutual labels:  table, sheet
Go Pretty
Pretty print tables and more in golang!
Stars: ✭ 777 (+497.69%)
Mutual labels:  ascii, table
Csconsoleformat
.NET C# library for advanced formatting of console output [Apache]
Stars: ✭ 296 (+127.69%)
Mutual labels:  text, ascii
outfancy
Python3 library to print tables in Terminal.
Stars: ✭ 47 (-63.85%)
Mutual labels:  ascii, table
react-native-styled-text
Styled Text for React Native
Stars: ✭ 57 (-56.15%)
Mutual labels:  text, format
vue-table-for
Easily build a table for your records
Stars: ✭ 33 (-74.62%)
Mutual labels:  table

table

Build Status Coverage Status GoDoc

Produces a string that represents slice of structs data in a text table, inspired by gajus/table.

Features:

  • No dependency.
  • Cell content aligned.
  • Column width self-adaptation
  • Support type of struct field: int, float, string, bool, slice, struct, map, time.Time and everything.
  • Support custom table header by declaring optional tag: table.(Thanks @skyfireitdiy)

Installation

$ go get github.com/modood/table

Quick start

package main

import (
	"github.com/modood/table"
)

type House struct {
	Name  string `table:"Name"`
	Sigil string
	Motto string
}

func main() {
	hs := []House{
		{"Stark", "direwolf", "Winter is coming"},
		{"Targaryen", "dragon", "Fire and Blood"},
		{"Lannister", "lion", "Hear Me Roar"},
	}

	// Output to stdout
	table.Output(hs)

	// Or just return table string and then do something
	s := table.Table(hs)
	_ = s
}

output:

┌───────────┬──────────┬──────────────────┐
│ Name      │ Sigil    │ Motto            │
├───────────┼──────────┼──────────────────┤
│ Stark     │ direwolf │ Winter is coming │
│ Targaryen │ dragon   │ Fire and Blood   │
│ Lannister │ lion     │ Hear Me Roar     │
└───────────┴──────────┴──────────────────┘

Document

  • func Output(slice interface{})

    formats slice of structs data and writes to standard output.(Using box drawing characters)

  • func OutputA(slice interface{})

    formats slice of structs data and writes to standard output.(Using standard ascii characters)

  • func Table(slice interface{}) string

    formats slice of structs data and returns the resulting string.(Using box drawing characters)

  • func AsciiTable(slice interface{}) string

    formats slice of structs data and returns the resulting string.(Using standard ascii characters)

  • compare box drawing characters with standard ascii characters

    box drawing:

    ┌───────────┬──────────┬──────────────────┐
    │ Name      │ Sigil    │ Motto            │
    ├───────────┼──────────┼──────────────────┤
    │ Stark     │ direwolf │ Winter is coming │
    │ Targaryen │ dragon   │ Fire and Blood   │
    │ Lannister │ lion     │ Hear Me Roar     │
    └───────────┴──────────┴──────────────────┘
    

    standard ascii:

    +-----------+----------+------------------+
    | Name      | Sigil    | Motto            |
    +-----------+----------+------------------+
    | Stark     | direwolf | Winter is coming |
    | Targaryen | dragon   | Fire and Blood   |
    | Lannister | lion     | Hear Me Roar     |
    +-----------+----------+------------------+
    

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

this repo is released under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].