All Projects → InVisionApp → tabular

InVisionApp / tabular

Licence: MIT License
Tabular simplifies printing ASCII tables from command line utilities

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to tabular

Hyde
Call of Duty XAsset compiler that transforms raw assets into digestible data.
Stars: ✭ 15 (-75.81%)
Mutual labels:  tables
Alhambra-II-FPGA
🌟 Alhambra II FPGA board
Stars: ✭ 63 (+1.61%)
Mutual labels:  opensource
hacktoberfest20
Participate in Hacktoberfest by contributing to any Open Source project on GitHub! Here is a starter project for first-time contributors. #hacktoberfest20. Don’t forget to read the README.md for guidance.
Stars: ✭ 18 (-70.97%)
Mutual labels:  opensource
opensource
Open source processes, policies, and info
Stars: ✭ 29 (-53.23%)
Mutual labels:  opensource
opencartbrasil
O projeto OpenCart Brasil é uma plataforma gratuita de loja online para lojistas brasileiros.
Stars: ✭ 55 (-11.29%)
Mutual labels:  opensource
documentation
Pterodactyl's documentation is open source! This repository contains the documentation for installing and updating both the panel and the daemon.
Stars: ✭ 99 (+59.68%)
Mutual labels:  opensource
pingping
Building a real world SaaS with Laravel, TailwindCSS and VueJS
Stars: ✭ 97 (+56.45%)
Mutual labels:  opensource
bulma-components
Bulma CSS Components - Open-Source project
Stars: ✭ 43 (-30.65%)
Mutual labels:  opensource
RooCMS
RooCMS - This is easy and convenient content management system designed to quickly create websites.
Stars: ✭ 21 (-66.13%)
Mutual labels:  opensource
NearBeach
NearBeach is an open sourced project management tool, helping you keep track of your project. You can track requirements, projects and tasks
Stars: ✭ 97 (+56.45%)
Mutual labels:  opensource
bootiful
Open-source, bare, modern Bootstrap v5 theme
Stars: ✭ 47 (-24.19%)
Mutual labels:  opensource
OpenSource-progammes
Resources for CODXCRYPT session
Stars: ✭ 14 (-77.42%)
Mutual labels:  opensource
MS-Office-Electron
A Microsoft Office Online Desktop Client made with Electron. Free of Cost.
Stars: ✭ 45 (-27.42%)
Mutual labels:  opensource
CoronaTracker
A full stack framework to trace possible close-contact candidates within last specified days for an already detected covid-19 positive patient
Stars: ✭ 13 (-79.03%)
Mutual labels:  opensource
Theatherflix
Theatherflix OpenSource Project - A visual tool for wiring digital movies, to sort and list the top latest movie trailers. We are constantly developing and making changes. Do you want to be part? Contact us!
Stars: ✭ 51 (-17.74%)
Mutual labels:  opensource
mviewer
Visualiseur géographique thématique basé sur OpenLayers 6.3.1 et Bootstrap 3.3.6 / cartographic application based on OpenLayers and Bootstrap
Stars: ✭ 53 (-14.52%)
Mutual labels:  opensource
magnusbilling7
MagnusBilling is a fast, secure, efficient, high availability, VOIP Billing.
Stars: ✭ 136 (+119.35%)
Mutual labels:  opensource
st-device-sdk-c
SmartThings SDK for Direct Connected Devices for C
Stars: ✭ 75 (+20.97%)
Mutual labels:  opensource
time-api
Nodejs API for Wobbly Time Tracker for the Teams
Stars: ✭ 24 (-61.29%)
Mutual labels:  opensource
gobo.icu
URL Shortener For Scratch
Stars: ✭ 14 (-77.42%)
Mutual labels:  opensource

LICENSE Build Status codecov Go Report Card Godocs

tabular

Tabular simplifies printing ASCII tables from command line utilities without the need to pass large sets of data to it's API.

Simply define the table columns and tabular will parse the right format specifier that you can use in your calls to fmt.Printf() or any other function that supports it.

Table columns can be defined once and then reused over and over again making it easy to modify column length and heading in one place. And a subset of columns can be specified during tabular.Print() or tabular.Parse() calls to modify the table's title without redefining it.

Example (also available in example/example.go):

package main

import (
	"fmt"
	"log"

	"github.com/InVisionApp/tabular"
)

var tab tabular.Table

func init() {
	tab = tabular.New()
	tab.Col("env", "Environment", 14)
	tab.Col("cls", "Cluster", 10)
	tab.Col("svc", "Service", 15)
	tab.Col("hst", "Database Host", 20)
	tab.ColRJ("pct", "%CPU", 7)
}

var data = []struct {
	e, c, s, d string
	v          float64
}{
	{
		e: "production",
		c: "cluster-1",
		s: "service-a",
		d: "database-host-1",
		v: 70.01,
	},
	{
		e: "production",
		c: "cluster-1",
		s: "service-b",
		d: "database-host-2",
		v: 99.51,
	},
	{
		e: "production",
		c: "cluster-2",
		s: "service-a",
		d: "database-host-1",
		v: 70.01,
	},
	{
		e: "production",
		c: "cluster-2",
		s: "service-b",
		d: "database-host-2",
		v: 99.51,
	},
}

func main() {
	// Print a subset of columns (Environments and Clusters)
	format := tab.Print("env", "cls")
	for _, x := range data {
		fmt.Printf(format, x.e, x.c)
	}

	// Print All Columns
	format = tab.Print("*")
	for _, x := range data {
		fmt.Printf(format, x.e, x.c, x.s, x.d, x.v)
	}

	// Print All Columns to a custom destination such as a log
	table := tab.Parse("*")
	log.Println(table.Header)
	log.Println(table.SubHeader)
	for _, x := range data {
		log.Printf(table.Format, x.e, x.c, x.s, x.d, x.v)
	}
}

Produces:

Environment    Cluster
-------------- ----------
production     cluster-1
production     cluster-1
production     cluster-2
production     cluster-2

Environment    Cluster    Service         Database Host           %CPU
-------------- ---------- --------------- -------------------- -------
production     cluster-1  service-a       database-host-1        70.01
production     cluster-1  service-b       database-host-2        99.51
production     cluster-2  service-a       database-host-1        70.01
production     cluster-2  service-b       database-host-2        99.51

2018/05/14 11:19:41 Environment    Cluster    Service         Database Host           %CPU
2018/05/14 11:19:41 -------------- ---------- --------------- -------------------- -------
2018/05/14 11:19:41 production     cluster-1  service-a       database-host-1        70.01
2018/05/14 11:19:41 production     cluster-1  service-b       database-host-2        99.51
2018/05/14 11:19:41 production     cluster-2  service-a       database-host-1        70.01
2018/05/14 11:19:41 production     cluster-2  service-b       database-host-2        99.51
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].