Skip to content

Commit c4a74ee

Browse files
luo6luo6
luo6
authored and
luo6
committed
update
1 parent 5fd6d50 commit c4a74ee

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed

README.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
# Terminal Table
77

8+
![example](./example.png)
9+
810
### How To Use
911

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

1618
table.Show([]string{"Module", "Type", "Path", "Author"}, [][]string{
17-
{"1", "2", "3", "4"},
19+
{"1", "2", "3", "4"},
1820
{"1", "2", "3", "4"},
1921
{"1", "2", "3", "4"},
2022
{"1", "2", "3", "4"},
2123
})
2224
```
2325

24-
![example](./example.png)
2526

2627
### Config
2728
```go
2829
var MaxCellWidth = 40
29-
var LineEndTag = "*"
30+
var LineEndTag = "+"
3031
var LineBody = "-"
3132
var LineDivider = "|"
3233
```
34+
3335
Example
3436
```go
3537
func TestShow(t *testing.T) {
@@ -55,6 +57,33 @@ Display
5557
/ 1 / 2 / 3 / 4 /
5658
*========*======*======*========*
5759
```
60+
61+
### Auto warp
62+
63+
```go
64+
MaxCellWidth = 20 // default 40
65+
Show([]string{"Module", "Type", "Path", "Author"}, [][]string{
66+
{"11111111111111111111111111111111111111", "2", "3", "4"},
67+
{"1", "2", "3", "4"},
68+
{"1", "2", "3", "4"},
69+
{"1", "2", "3", "4"},
70+
})
71+
72+
73+
```
74+
75+
```go
76+
+----------------------+------+------+--------+
77+
| Module | Type | Path | Author |
78+
+----------------------+------+------+--------+
79+
| 11111111111111111111 | 2 | 3 | 4 |
80+
| 111111111111111111 | | | |
81+
| 1 | 2 | 3 | 4 |
82+
| 1 | 2 | 3 | 4 |
83+
| 1 | 2 | 3 | 4 |
84+
+----------------------+------+------+--------+
85+
```
86+
5887
## MIT License
5988

6089
Copyright (c) 2022 ICU-Coders

example.png

1.8 KB
Loading

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
var MaxCellWidth = 40
10-
var LineEndTag = "*"
10+
var LineEndTag = "+"
1111
var LineBody = "-"
1212
var LineDivider = "|"
1313

main_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package table
33
import "testing"
44

55
func TestShow(t *testing.T) {
6-
LineEndTag = "*"
7-
LineBody = "="
8-
LineDivider = "/"
6+
//LineEndTag = "*"
7+
//LineBody = "="
8+
//LineDivider = "/"
9+
MaxCellWidth = 20
910
Show([]string{"Module", "Type", "Path", "Author"}, [][]string{
10-
{"1111", "2", "3", "4"},
11+
{"11111111111111111111111111111111111111", "2", "3", "4"},
1112
{"1", "2", "3", "4"},
1213
{"1", "2", "3", "4"},
1314
{"1", "2", "3", "4"},

0 commit comments

Comments
 (0)