MCPcopy
hub / github.com/pterm/pterm / main

Function main

_examples/theme/demo/main.go:9–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7)
8
9func main() {
10 // Print an informational message about the default theme styles.
11 pterm.Info.Println("These are the default theme styles.\nYou can modify them easily to your personal preference,\nor create new themes from scratch :)")
12
13 // Print a blank line for better readability.
14 pterm.Println()
15
16 // Get the value and type of the default theme.
17 v := reflect.ValueOf(pterm.ThemeDefault)
18 typeOfS := v.Type()
19
20 // Check if the type of the default theme is 'pterm.Theme'.
21 if typeOfS == reflect.TypeOf(pterm.Theme{}) {
22 // Iterate over each field in the default theme.
23 for i := 0; i < v.NumField(); i++ {
24 // Try to convert the field to 'pterm.Style'.
25 field, ok := v.Field(i).Interface().(pterm.Style)
26 if ok {
27 // Print the field name using its own style.
28 field.Println(typeOfS.Field(i).Name)
29 }
30 // Pause for a quarter of a second to make the output easier to read.
31 time.Sleep(time.Millisecond * 250)
32 }
33 }
34}

Callers

nothing calls this directly

Calls 2

PrintlnFunction · 0.92
PrintlnMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…