-
Notifications
You must be signed in to change notification settings - Fork 123
/
examples.go
35 lines (31 loc) · 998 Bytes
/
examples.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"math/rand"
"regexp"
)
var examples = map[string]string{
"Write new sections for a readme": `cat README.md | mods "write a new section to this README documenting a pdf sharing feature"`,
"Editorialize your video files": `ls ~/vids | mods -f "summarize each of these titles, group them by decade" | glow`,
"Let GPT pick something to watch": `ls ~/vids | mods "Pick 5 action packed shows from the 80s from this list" | gum choose | xargs vlc`,
}
func randomExample() string {
keys := make([]string, 0, len(examples))
for k := range examples {
keys = append(keys, k)
}
desc := keys[rand.Intn(len(keys))] //nolint:gosec
return desc
}
func cheapHighlighting(s styles, code string) string {
code = regexp.
MustCompile(`"([^"\\]|\\.)*"`).
ReplaceAllStringFunc(code, func(x string) string {
return s.Quote.Render(x)
})
code = regexp.
MustCompile(`\|`).
ReplaceAllStringFunc(code, func(x string) string {
return s.Pipe.Render(x)
})
return code
}