Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
luo6 authored and luo6 committed Aug 5, 2022
1 parent 5fd6d50 commit c4a74ee
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

# Terminal Table

![example](./example.png)

### How To Use

```shell
Expand All @@ -14,22 +16,22 @@ go get github.com/ICU-Coders/table
import "github.com/ICU-Coders/table"

table.Show([]string{"Module", "Type", "Path", "Author"}, [][]string{
{"1", "2", "3", "4"},
{"1", "2", "3", "4"},
{"1", "2", "3", "4"},
{"1", "2", "3", "4"},
{"1", "2", "3", "4"},
})
```

![example](./example.png)

### Config
```go
var MaxCellWidth = 40
var LineEndTag = "*"
var LineEndTag = "+"
var LineBody = "-"
var LineDivider = "|"
```

Example
```go
func TestShow(t *testing.T) {
Expand All @@ -55,6 +57,33 @@ Display
/ 1 / 2 / 3 / 4 /
*========*======*======*========*
```

### Auto warp

```go
MaxCellWidth = 20 // default 40
Show([]string{"Module", "Type", "Path", "Author"}, [][]string{
{"11111111111111111111111111111111111111", "2", "3", "4"},
{"1", "2", "3", "4"},
{"1", "2", "3", "4"},
{"1", "2", "3", "4"},
})


```

```go
+----------------------+------+------+--------+
| Module | Type | Path | Author |
+----------------------+------+------+--------+
| 11111111111111111111 | 2 | 3 | 4 |
| 111111111111111111 | | | |
| 1 | 2 | 3 | 4 |
| 1 | 2 | 3 | 4 |
| 1 | 2 | 3 | 4 |
+----------------------+------+------+--------+
```

## MIT License

Copyright (c) 2022 ICU-Coders
Expand Down
Binary file modified example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

var MaxCellWidth = 40
var LineEndTag = "*"
var LineEndTag = "+"
var LineBody = "-"
var LineDivider = "|"

Expand Down
9 changes: 5 additions & 4 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package table
import "testing"

func TestShow(t *testing.T) {
LineEndTag = "*"
LineBody = "="
LineDivider = "/"
//LineEndTag = "*"
//LineBody = "="
//LineDivider = "/"
MaxCellWidth = 20
Show([]string{"Module", "Type", "Path", "Author"}, [][]string{
{"1111", "2", "3", "4"},
{"11111111111111111111111111111111111111", "2", "3", "4"},
{"1", "2", "3", "4"},
{"1", "2", "3", "4"},
{"1", "2", "3", "4"},
Expand Down

0 comments on commit c4a74ee

Please sign in to comment.