{"id":13410130,"url":"https://github.com/InVisionApp/tabular","last_synced_at":"2025-03-14T15:31:52.299Z","repository":{"id":45831128,"uuid":"130757857","full_name":"InVisionApp/tabular","owner":"InVisionApp","description":"Tabular simplifies printing ASCII tables from command line utilities","archived":false,"fork":false,"pushed_at":"2023-05-12T01:35:13.000Z","size":17,"stargazers_count":76,"open_issues_count":0,"forks_count":7,"subscribers_count":100,"default_branch":"master","last_synced_at":"2024-08-06T15:19:43.568Z","etag":null,"topics":["cli","go","golang","opensource","tables"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/InVisionApp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null}},"created_at":"2018-04-23T21:17:03.000Z","updated_at":"2023-12-25T13:44:01.000Z","dependencies_parsed_at":"2023-12-11T21:47:46.017Z","dependency_job_id":null,"html_url":"https://github.com/InVisionApp/tabular","commit_stats":{"total_commits":19,"total_committers":2,"mean_commits":9.5,"dds":"0.052631578947368474","last_synced_commit":"b82b48e05e72d6859ee7909fcda9fbf66e8191a7"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InVisionApp%2Ftabular","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InVisionApp%2Ftabular/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InVisionApp%2Ftabular/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InVisionApp%2Ftabular/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/InVisionApp","download_url":"https://codeload.github.com/InVisionApp/tabular/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243600671,"owners_count":20317313,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","go","golang","opensource","tables"],"created_at":"2024-07-30T20:01:05.121Z","updated_at":"2025-03-14T15:31:52.293Z","avatar_url":"https://github.com/InVisionApp.png","language":"Go","readme":"| :warning: This project is no longer actively supported.\n| ---\n\n[![LICENSE](https://img.shields.io/badge/license-MIT-orange.svg)](LICENSE)\n[![Build Status](https://travis-ci.org/InVisionApp/tabular.svg?branch=master)](https://travis-ci.org/InVisionApp/tabular)\n[![codecov](https://codecov.io/gh/InVisionApp/tabular/branch/master/graph/badge.svg)](https://codecov.io/gh/InVisionApp/tabular)\n[![Go Report Card](https://goreportcard.com/badge/github.com/InVisionApp/tabular)](https://goreportcard.com/report/github.com/InVisionApp/tabular)\n[![Godocs](https://img.shields.io/badge/golang-documentation-blue.svg)](https://godoc.org/github.com/InVisionApp/tabular)\n\n# tabular\n\nTabular simplifies printing ASCII tables from command line utilities without the need to pass large sets of data to it's API.  \n\nSimply define the table columns and `tabular` will parse the right [format specifier](https://golang.org/pkg/fmt/#Printf) that you can use in your calls to `fmt.Printf()` or any other function that supports it.\n\nTable 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.\n\nExample (also available in [`example/example.go`](example/example.go)):\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/InVisionApp/tabular\"\n)\n\nvar tab tabular.Table\n\nfunc init() {\n\ttab = tabular.New()\n\ttab.Col(\"env\", \"Environment\", 14)\n\ttab.Col(\"cls\", \"Cluster\", 10)\n\ttab.Col(\"svc\", \"Service\", 15)\n\ttab.Col(\"hst\", \"Database Host\", 20)\n\ttab.ColRJ(\"pct\", \"%CPU\", 7)\n}\n\nvar data = []struct {\n\te, c, s, d string\n\tv          float64\n}{\n\t{\n\t\te: \"production\",\n\t\tc: \"cluster-1\",\n\t\ts: \"service-a\",\n\t\td: \"database-host-1\",\n\t\tv: 70.01,\n\t},\n\t{\n\t\te: \"production\",\n\t\tc: \"cluster-1\",\n\t\ts: \"service-b\",\n\t\td: \"database-host-2\",\n\t\tv: 99.51,\n\t},\n\t{\n\t\te: \"production\",\n\t\tc: \"cluster-2\",\n\t\ts: \"service-a\",\n\t\td: \"database-host-1\",\n\t\tv: 70.01,\n\t},\n\t{\n\t\te: \"production\",\n\t\tc: \"cluster-2\",\n\t\ts: \"service-b\",\n\t\td: \"database-host-2\",\n\t\tv: 99.51,\n\t},\n}\n\nfunc main() {\n\t// Print a subset of columns (Environments and Clusters)\n\tformat := tab.Print(\"env\", \"cls\")\n\tfor _, x := range data {\n\t\tfmt.Printf(format, x.e, x.c)\n\t}\n\n\t// Print All Columns\n\tformat = tab.Print(\"*\")\n\tfor _, x := range data {\n\t\tfmt.Printf(format, x.e, x.c, x.s, x.d, x.v)\n\t}\n\n\t// Print All Columns to a custom destination such as a log\n\ttable := tab.Parse(\"*\")\n\tlog.Println(table.Header)\n\tlog.Println(table.SubHeader)\n\tfor _, x := range data {\n\t\tlog.Printf(table.Format, x.e, x.c, x.s, x.d, x.v)\n\t}\n}\n```\n\nProduces:\n\n```\nEnvironment    Cluster\n-------------- ----------\nproduction     cluster-1\nproduction     cluster-1\nproduction     cluster-2\nproduction     cluster-2\n\nEnvironment    Cluster    Service         Database Host           %CPU\n-------------- ---------- --------------- -------------------- -------\nproduction     cluster-1  service-a       database-host-1        70.01\nproduction     cluster-1  service-b       database-host-2        99.51\nproduction     cluster-2  service-a       database-host-1        70.01\nproduction     cluster-2  service-b       database-host-2        99.51\n\n2018/05/14 11:19:41 Environment    Cluster    Service         Database Host           %CPU\n2018/05/14 11:19:41 -------------- ---------- --------------- -------------------- -------\n2018/05/14 11:19:41 production     cluster-1  service-a       database-host-1        70.01\n2018/05/14 11:19:41 production     cluster-1  service-b       database-host-2        99.51\n2018/05/14 11:19:41 production     cluster-2  service-a       database-host-1        70.01\n2018/05/14 11:19:41 production     cluster-2  service-b       database-host-2        99.51\n```\n","funding_links":[],"categories":["Command Line","命令行","高级控制台UI","Build Automation","高级控制台UI`用于构建控制台应用程序和控制台用户界面的库.`"],"sub_categories":["Advanced Console UIs","高级控制台用户界面","标准 CLI"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FInVisionApp%2Ftabular","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FInVisionApp%2Ftabular","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FInVisionApp%2Ftabular/lists"}