Skip to content

Commit f248369

Browse files
committed
first commit
0 parents  commit f248369

File tree

319 files changed

+163845
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

319 files changed

+163845
-0
lines changed

.github/ISSUE_TEMPLATE.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Expected Behavior
2+
3+
4+
## Actual Behavior
5+
6+
7+
## Steps to Reproduce the Problem
8+
1.
9+
1.
10+
1.
11+
12+
## Specifications
13+
- Platform:
14+
- Version:

.github/PULL_REQUEST_TEMPLATE.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## Proposed Changes
2+
-
3+
-
4+
-
5+
6+
Fixes #<insert Issue # here if applicable>.

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.idea/

.travis.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
language: go
2+
3+
# Use the latest version.
4+
go: 1.10.x
5+
6+
# Skip the install step. Everything needed should be in the /vendor folder.
7+
install: true
8+
9+
# Don't email the results of the test.
10+
notifications:
11+
email: false
12+
13+
# Commands to run before executing the "script" section.
14+
before_script:
15+
- go get -u golang.org/x/lint/golint
16+
- go get -u github.com/fzipp/gocyclo
17+
18+
# CI Pipeline.
19+
script:
20+
- make test
21+
- make bench

CODE_OF_CONDUCT.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

Gopkg.lock

+63
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Gopkg.toml example
2+
#
3+
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
4+
# for detailed Gopkg.toml documentation.
5+
#
6+
# required = ["github.com/user/thing/cmd/thing"]
7+
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
8+
#
9+
# [[constraint]]
10+
# name = "github.com/user/project"
11+
# version = "1.0.0"
12+
#
13+
# [[constraint]]
14+
# name = "github.com/user/project2"
15+
# branch = "dev"
16+
# source = "github.com/myfork/project2"
17+
#
18+
# [[override]]
19+
# name = "github.com/x/y"
20+
# version = "2.4.0"
21+
#
22+
# [prune]
23+
# non-go = false
24+
# go-tests = true
25+
# unused-packages = true
26+
27+
28+
[[constraint]]
29+
name = "github.com/stretchr/testify"
30+
version = "1.2.1"
31+
32+
[prune]
33+
go-tests = true
34+
unused-packages = true

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 jedib0t
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.PHONY: all dep gen test
2+
3+
default: build
4+
5+
all: dep test bench
6+
7+
tools:
8+
go get -u golang.org/x/lint/golint
9+
go get -u github.com/fzipp/gocyclo
10+
go get -u github.com/golang/dep/cmd/dep
11+
go get -u github.com/golang/mock/gomock
12+
go install github.com/golang/mock/mockgen
13+
14+
bench:
15+
go test -bench . -benchmem
16+
17+
build: gen
18+
go run demo/demo.go
19+
20+
cyclo:
21+
gocyclo -over 10 ./*.go
22+
23+
dep:
24+
dep ensure
25+
26+
gen:
27+
go generate $(shell go list .)
28+
29+
lint:
30+
golint $(shell go list .)
31+
32+
test: lint vet cyclo
33+
go test -cover $(shell go list .)
34+
35+
vet:
36+
go vet $(shell go list .)

README.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# go-pretty
2+
3+
[![Build Status](https://travis-ci.org/jedib0t/go-pretty.svg?branch=master)](https://travis-ci.org/jedib0t/go-pretty)
4+
[![GoDoc](https://godoc.org/github.com/jedib0t/go-pretty?status.svg)](https://godoc.org/github.com/jedib0t/go-pretty)
5+
[![Go Report Card](https://goreportcard.com/badge/github.com/jedib0t/go-pretty)](https://goreportcard.com/report/github.com/jedib0t/go-pretty)
6+
7+
Utilities to prettify console output of tables, lists, etc.
8+
9+
## Table
10+
11+
Pretty-print tables into ASCII/Unicode strings.
12+
13+
- Supports Header and Footer
14+
- Supports Adding Rows one-by-one or as a group
15+
- Auto (horizontal) Alignment (numeric columns are aligned Right)
16+
- Custom (horizontal) Alignment per column
17+
- Custom (vertical) VAlignment per column (and multi-line column support)
18+
- Completely customizable styles
19+
- Many ready-to-use styles: [table_style.go](table_style.go)
20+
- Colorize Headers/Body/Footers using [github.com/fatih/color][fatih.color]
21+
- Custom text-case for Headers/Body/Footers
22+
- Enable separators between each row
23+
- Render table without a Border
24+
- Render as:
25+
- (ASCII/Unicode) Table
26+
- CSV
27+
- HTML Table (with custom CSS Style)
28+
29+
### Example
30+
31+
Run the [sample code](demo/table/table.go) using `go run demo/table/table.go` to get:
32+
33+
<img src="demo/table/table.png" width="600px"/>
34+
35+
## List
36+
37+
Pretty-print lists with multiple levels/indents into ASCII/Unicode strings.
38+
39+
- Completely customizable styles
40+
- Many ready-to-use styles: [list_style.go](list_style.go)
41+
42+
### Example
43+
44+
Run the [sample code](demo/list/list.go) using `go run demo/list/list.go` to get:
45+
46+
<img src="demo/list/list.png" width="600px"/>
47+
48+
## Benchmarks
49+
50+
```
51+
$ go test -bench . -benchmem
52+
goos: linux
53+
goarch: amd64
54+
pkg: github.com/jedib0t/go-pretty
55+
BenchmarkList_Render-8 1000000 1659 ns/op 608 B/op 24 allocs/op
56+
BenchmarkTable_Render-8 100000 23502 ns/op 6434 B/op 384 allocs/op
57+
BenchmarkTable_RenderCSV-8 300000 5402 ns/op 2641 B/op 89 allocs/op
58+
BenchmarkTable_RenderHTML-8 200000 7027 ns/op 4113 B/op 88 allocs/op
59+
PASS
60+
ok github.com/jedib0t/go-pretty 7.458s
61+
```
62+
63+
64+
[fatih.color]: https://github.com/fatih/color

constants.go

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package gopretty
2+
3+
// Unicode character constants for drawing borders & separators.
4+
const (
5+
BorderBottomLeft = "└" // \u2514 So BOX DRAWINGS LIGHT UP AND RIGHT
6+
BorderBottomLeftBold = "┗" // \u2517 So BOX DRAWINGS HEAVY UP AND RIGHT
7+
BorderBottomLeftDouble = "╚" // \u255A So BOX DRAWINGS DOUBLE UP AND RIGHT
8+
BorderBottomLeftRounded = "╰" // \u2570 So BOX DRAWINGS LIGHT ARC UP AND RIGHT
9+
BorderBottomRight = "┘" // \u2518 So BOX DRAWINGS LIGHT UP AND LEFT
10+
BorderBottomRightBold = "┛" // \u251B So BOX DRAWINGS HEAVY UP AND LEFT
11+
BorderBottomRightDouble = "╝" // \u255D So BOX DRAWINGS DOUBLE UP AND LEFT
12+
BorderBottomRightRounded = "╯" // \u256F So BOX DRAWINGS LIGHT ARC UP AND LEFT
13+
BorderBottomSeparator = "┴" // \u2534 So BOX DRAWINGS LIGHT UP AND HORIZONTAL
14+
BorderBottomSeparatorBold = "┻" // \u253B So BOX DRAWINGS HEAVY UP AND HORIZONTAL
15+
BorderBottomSeparatorDouble = "╩" // \u2569 So BOX DRAWINGS DOUBLE UP AND HORIZONTAL
16+
BorderHorizontal = "─" // \u2500 So BOX DRAWINGS LIGHT HORIZONTAL
17+
BorderHorizontalBold = "━" // \u2501 So BOX DRAWINGS HEAVY HORIZONTAL
18+
BorderHorizontalDouble = "═" // \u2550 So BOX DRAWINGS DOUBLE HORIZONTAL
19+
BorderLeft = BorderVertical
20+
BorderLeftBold = BorderVerticalBold
21+
BorderLeftDouble = BorderVerticalDouble
22+
BorderLeftSeparator = "├" // \u251C So BOX DRAWINGS LIGHT VERTICAL AND RIGHT
23+
BorderLeftSeparatorBold = "┣" // \u2523 So BOX DRAWINGS HEAVY VERTICAL AND RIGHT
24+
BorderLeftSeparatorDouble = "╠" // \u2560 So BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
25+
BorderRight = BorderVertical
26+
BorderRightBold = BorderVerticalBold
27+
BorderRightDouble = BorderVerticalDouble
28+
BorderRightSeparator = "┤" // \u2524 So BOX DRAWINGS LIGHT VERTICAL AND LEFT
29+
BorderRightSeparatorBold = "┫" // \u252B So BOX DRAWINGS HEAVY VERTICAL AND LEFT
30+
BorderRightSeparatorDouble = "╣" // \u2563 So BOX DRAWINGS DOUBLE VERTICAL AND LEFT
31+
BorderSeparator = "┼" // \u253C So BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
32+
BorderSeparatorBold = "╋" // \u254B So BOX DRAWINGS HEAVY VERTICAL AND HORIZONTAL
33+
BorderSeparatorDouble = "╬" // \u256C So BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
34+
BorderTopLeft = "┌" // \u250C So BOX DRAWINGS LIGHT DOWN AND RIGHT
35+
BorderTopLeftBold = "┏" // \u250F So BOX DRAWINGS HEAVY DOWN AND RIGHT
36+
BorderTopLeftDouble = "╔" // \u2554 So BOX DRAWINGS DOUBLE DOWN AND RIGHT
37+
BorderTopLeftRounded = "╭" // \u256D So BOX DRAWINGS LIGHT ARC DOWN AND RIGHT
38+
BorderTopRight = "┐" // \u2510 So BOX DRAWINGS LIGHT DOWN AND LEFT
39+
BorderTopRightBold = "┓" // \u2513 So BOX DRAWINGS HEAVY DOWN AND LEFT
40+
BorderTopRightDouble = "╗" // \u2557 So BOX DRAWINGS DOUBLE DOWN AND LEFT
41+
BorderTopRightRounded = "╮" // \u256E So BOX DRAWINGS LIGHT ARC DOWN AND LEFT
42+
BorderTopSeparator = "┬" // \u252C So BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
43+
BorderTopSeparatorBold = "┳" // \u2533 So BOX DRAWINGS HEAVY DOWN AND HORIZONTAL
44+
BorderTopSeparatorDouble = "╦" // \u2566 So BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
45+
BorderVertical = "│" // \u2502 So BOX DRAWINGS LIGHT VERTICAL
46+
BorderVerticalBold = "┃" // \u2503 So BOX DRAWINGS HEAVY VERTICAL
47+
BorderVerticalDouble = "║" // \u2551 So BOX DRAWINGS DOUBLE VERTICAL
48+
BulletCircle = "●" // \u25CF So BLACK CIRCLE
49+
BulletFlower = "✽" // \u273D So HEAVY TEARDROP-SPOKED ASTERISK
50+
BulletSquare = "■" // \u25A0 So BLACK SQUARE
51+
BulletStar = "★" // \u272E So BLACK STAR
52+
BulletTrianglePointingDown = "▼" // \u25BC So BLACK DOWN-POINTING TRIANGLE
53+
BulletTrianglePointingLeft = "◀" // \u25C0 So BLACK LEFT-POINTING TRIANGLE
54+
BulletTrianglePointingRight = "▶" // \u25B6 So BLACK RIGHT-POINTING TRIANGLE
55+
BulletTrianglePointingTop = "▲" // \u25B2 So BLACK UP-POINTING TRIANGLE
56+
)

0 commit comments

Comments
 (0)