Skip to content

Commit

Permalink
examples(table): added more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinJWendt committed Mar 4, 2023
1 parent 1a95c8a commit c69f5ba
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
14 changes: 14 additions & 0 deletions _examples/table/boxed/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import "github.com/pterm/pterm"

func main() {
// Create a fork of the default table, fill it with data and print it.
// Data can also be generated and inserted later.
pterm.DefaultTable.WithHasHeader().WithBoxed().WithData(pterm.TableData{
{"Firstname", "Lastname", "Email", "Note"},
{"Paul", "Dean", "nisi.dictum.augue@velitAliquam.co.uk", ""},
{"Callie", "Mckay", "egestas.nunc.sed@est.com", "这是一个测试, haha!"},
{"Libby", "Camacho", "aliquet.lobortis@semper.com", "just a test, hey!"},
}).Render()
}
14 changes: 14 additions & 0 deletions _examples/table/multiple-lines/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import "github.com/pterm/pterm"

func main() {
// Create a table with multiple lines in a row and set a row separator.
pterm.DefaultTable.WithHasHeader().WithRowSeparator("-").WithHeaderRowSeparator("-").WithData(pterm.TableData{
{"Firstname", "Lastname", "Email"},
{"Paul\n\nNewline", "Dean", "nisi.dictum.augue@velitAliquam.co.uk"},
{"Callie", "Mckay", "egestas.nunc.sed@est.com\nNewline"},
{"Libby", "Camacho", "aliquet.lobortis@semper.com"},
{"张", "小宝", "zhang@example.com"},
}).Render()
}
14 changes: 14 additions & 0 deletions _examples/table/right-alignment/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import "github.com/pterm/pterm"

func main() {
// Create a fork of the default table, fill it with data and print it.
// Data can also be generated and inserted later.
pterm.DefaultTable.WithHasHeader().WithRightAlignment().WithData(pterm.TableData{
{"Firstname", "Lastname", "Email", "Note"},
{"Paul", "Dean", "nisi.dictum.augue@velitAliquam.co.uk", ""},
{"Callie", "Mckay", "egestas.nunc.sed@est.com", "这是一个测试, haha!"},
{"Libby", "Camacho", "aliquet.lobortis@semper.com", "just a test, hey!"},
}).Render()
}

0 comments on commit c69f5ba

Please sign in to comment.