clitable

package module
v0.0.0-...-2488a87 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2022 License: Unlicense Imports: 3 Imported by: 33

README

go-clitable

Deprecated in favor of olekukonko/tablewriter

GoDoc

ASCII and Markdown tables in console for golang.

Usage

Print table
table := New([]string{"Name", "Host", "..."})
table.AddRow(map[string]interface{}{"Name": "..."})
table.Print()
|----------------------------------------------------------------------------------------|
| Name              | Host                 | Type             | _id                      |
|----------------------------------------------------------------------------------------|
| MongoLab          | mongolab.com         | MongoDB Provider | 52518c5d56357d17ec000002 |
|----------------------------------------------------------------------------------------|
| Google App Engine | appengine.google.com | App Engine       | 52518ff356357d17ec000004 |
|----------------------------------------------------------------------------------------|
| Heroku            | heroku.com           | App Engine       | 5251918e56357d17ec000005 |
|----------------------------------------------------------------------------------------|
Horizontal table
table.PrintHorizontal(map[string]interface{}{
	"Name": "MongoLab",
	"Host": "mongolab.com",
})
|---------------------------------|
| Name | MongoLab                 |
|---------------------------------|
| Host | mongolab.com             |
|---------------------------------|
| Type | MongoDB Provider         |
|---------------------------------|
| _id  | 52518c5d56357d17ec000002 |
|---------------------------------|
Markdown table
table := New([]string{"Name", "Host", "..."})
table.AddRow(map[string]interface{}{"Name": "..."})
table.Markdown = true
table.Print()
| Name              | Host                 | Type             | _id                      |
| ----------------- | -------------------- | ---------------- | ------------------------ |
| MongoLab          | mongolab.com         | MongoDB Provider | 52518c5d56357d17ec000002 |
| Google App Engine | appengine.google.com | App Engine       | 52518ff356357d17ec000004 |
| Heroku            | heroku.com           | App Engine       | 5251918e56357d17ec000005 |
Name Host Type _id
MongoLab mongolab.com MongoDB Provider 52518c5d56357d17ec000002
Google App Engine appengine.google.com App Engine 52518ff356357d17ec000004
Heroku heroku.com App Engine 5251918e56357d17ec000005

License

Unlicensed. For more information, please refer to http://unlicense.org.

Documentation

Overview

Package clitable implements methods for pretty command line table output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintHorizontal

func PrintHorizontal(m map[string]interface{})

PrintHorizontal - Prints horizontal table from a map.

func PrintRow

func PrintRow(fields []string, row map[string]interface{})

PrintRow - Prints table with only one row.

func PrintTable

func PrintTable(fields []string, rows []map[string]interface{})

PrintTable - Prints table.

Types

type Table

type Table struct {
	Fields   []string
	Footer   map[string]string
	Rows     []map[string]string
	HideHead bool // when true doesn't print header
	Markdown bool
	// contains filtered or unexported fields
}

Table - Table structure.

func New

func New(fields []string) *Table

New - Creates a new table.

func (*Table) AddFooter

func (t *Table) AddFooter(footer map[string]string)

AddFooter - Adds footer to the table.

func (*Table) AddRow

func (t *Table) AddRow(row map[string]interface{})

AddRow - Adds row to the table.

func (*Table) Print

func (t *Table) Print()

Print - Prints table.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL