Skip to content

Commit

Permalink
added new dir structure to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinJWendt committed Apr 20, 2022
1 parent 2fd7960 commit 76ec959
Show file tree
Hide file tree
Showing 77 changed files with 1,088 additions and 1,084 deletions.
Empty file added README.md
Empty file.
4 changes: 4 additions & 0 deletions _examples/README.md
@@ -0,0 +1,4 @@
# PTerm Examples

> This directory contains examples of using the PTerm library.
@@ -1,20 +1,20 @@
# print-basic-text

![Animation](animation.svg)

```go
package main

import "github.com/pterm/pterm"

func main() {
// A BasicText printer is used to print text, without special formatting.
// As it implements the TextPrinter interface, you can use it in combination with other printers.
pterm.DefaultBasicText.Println("Default basic text printer.")
pterm.DefaultBasicText.Println("Can be used in any" + pterm.LightMagenta(" TextPrinter ") + "context.")
pterm.DefaultBasicText.Println("For example to resolve progressbars and spinners.")
// If you just want to print text, you should use this instead:
// pterm.Println("Hello, World!")
}

```
# print-basic-text

![Animation](animation.svg)

```go
package main

import "github.com/pterm/pterm"

func main() {
// A BasicText printer is used to print text, without special formatting.
// As it implements the TextPrinter interface, you can use it in combination with other printers.
pterm.DefaultBasicText.Println("Default basic text printer.")
pterm.DefaultBasicText.Println("Can be used in any" + pterm.LightMagenta(" TextPrinter ") + "context.")
pterm.DefaultBasicText.Println("For example to resolve progressbars and spinners.")
// If you just want to print text, you should use this instead:
// pterm.Println("Hello, World!")
}

```
File renamed without changes
File renamed without changes.
@@ -1,21 +1,21 @@
# bulletlist-custom

![Animation](animation.svg)

```go
package main

import (
"github.com/pterm/pterm"
)

func main() {
// Print a customized list with different styles and levels.
pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{
{Level: 0, Text: "Blue", TextStyle: pterm.NewStyle(pterm.FgBlue), BulletStyle: pterm.NewStyle(pterm.FgRed)},
{Level: 1, Text: "Green", TextStyle: pterm.NewStyle(pterm.FgGreen), Bullet: "-", BulletStyle: pterm.NewStyle(pterm.FgLightWhite)},
{Level: 2, Text: "Cyan", TextStyle: pterm.NewStyle(pterm.FgCyan), Bullet: ">", BulletStyle: pterm.NewStyle(pterm.FgYellow)},
}).Render()
}

```
# bulletlist-custom

![Animation](animation.svg)

```go
package main

import (
"github.com/pterm/pterm"
)

func main() {
// Print a customized list with different styles and levels.
pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{
{Level: 0, Text: "Blue", TextStyle: pterm.NewStyle(pterm.FgBlue), BulletStyle: pterm.NewStyle(pterm.FgRed)},
{Level: 1, Text: "Green", TextStyle: pterm.NewStyle(pterm.FgGreen), Bullet: "-", BulletStyle: pterm.NewStyle(pterm.FgLightWhite)},
{Level: 2, Text: "Cyan", TextStyle: pterm.NewStyle(pterm.FgCyan), Bullet: ">", BulletStyle: pterm.NewStyle(pterm.FgYellow)},
}).Render()
}

```
File renamed without changes
File renamed without changes.
40 changes: 20 additions & 20 deletions _examples/center/README.md → _examples/center/demo/README.md
@@ -1,20 +1,20 @@
# center

![Animation](animation.svg)

```go
package main

import "github.com/pterm/pterm"

func main() {
pterm.DefaultCenter.Println("This text is centered!\nIt centeres the whole block by default.\nIn that way you can do stuff like this:")

// Generate BigLetters
s, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString("PTerm")).Srender()
pterm.DefaultCenter.Println(s) // Print BigLetters with the default CenterPrinter

pterm.DefaultCenter.WithCenterEachLineSeparately().Println("This text is centered!\nBut each line is\ncentered\nseparately")
}

```
# center

![Animation](animation.svg)

```go
package main

import "github.com/pterm/pterm"

func main() {
pterm.DefaultCenter.Println("This text is centered!\nIt centeres the whole block by default.\nIn that way you can do stuff like this:")

// Generate BigLetters
s, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString("PTerm")).Srender()
pterm.DefaultCenter.Println(s) // Print BigLetters with the default CenterPrinter

pterm.DefaultCenter.WithCenterEachLineSeparately().Println("This text is centered!\nBut each line is\ncentered\nseparately")
}

```
File renamed without changes
File renamed without changes.
@@ -1,34 +1,34 @@
# print-with-color

![Animation](animation.svg)

```go
package main

import "github.com/pterm/pterm"

func main() {
// Print different colored words.
pterm.Println(pterm.Red("Hello, ") + pterm.Green("World") + pterm.Cyan("!"))
pterm.Println(pterm.Red("Even " + pterm.Cyan("nested ") + pterm.Green("colors ") + "are supported!"))

// Print strings with set color.
pterm.FgBlack.Println("FgBlack")
pterm.FgRed.Println("FgRed")
pterm.FgGreen.Println("FgGreen")
pterm.FgYellow.Println("FgYellow")
pterm.FgBlue.Println("FgBlue")
pterm.FgMagenta.Println("FgMagenta")
pterm.FgCyan.Println("FgCyan")
pterm.FgWhite.Println("FgWhite")
pterm.Println() // Print one line space.
pterm.FgLightRed.Println("FgLightRed")
pterm.FgLightGreen.Println("FgLightGreen")
pterm.FgLightYellow.Println("FgLightYellow")
pterm.FgLightBlue.Println("FgLightBlue")
pterm.FgLightMagenta.Println("FgLightMagenta")
pterm.FgLightCyan.Println("FgLightCyan")
pterm.FgLightWhite.Println("FgLightWhite")
}

```
# print-with-color

![Animation](animation.svg)

```go
package main

import "github.com/pterm/pterm"

func main() {
// Print different colored words.
pterm.Println(pterm.Red("Hello, ") + pterm.Green("World") + pterm.Cyan("!"))
pterm.Println(pterm.Red("Even " + pterm.Cyan("nested ") + pterm.Green("colors ") + "are supported!"))

// Print strings with set color.
pterm.FgBlack.Println("FgBlack")
pterm.FgRed.Println("FgRed")
pterm.FgGreen.Println("FgGreen")
pterm.FgYellow.Println("FgYellow")
pterm.FgBlue.Println("FgBlue")
pterm.FgMagenta.Println("FgMagenta")
pterm.FgCyan.Println("FgCyan")
pterm.FgWhite.Println("FgWhite")
pterm.Println() // Print one line space.
pterm.FgLightRed.Println("FgLightRed")
pterm.FgLightGreen.Println("FgLightGreen")
pterm.FgLightYellow.Println("FgLightYellow")
pterm.FgLightBlue.Println("FgLightBlue")
pterm.FgLightMagenta.Println("FgLightMagenta")
pterm.FgLightCyan.Println("FgLightCyan")
pterm.FgLightWhite.Println("FgLightWhite")
}

```
File renamed without changes
File renamed without changes.

0 comments on commit 76ec959

Please sign in to comment.