2023-04-18 01:59:33 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"math/rand"
|
2023-05-09 17:44:02 +00:00
|
|
|
"regexp"
|
2023-04-18 01:59:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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"`,
|
|
|
|
"Editorialze 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, string) {
|
|
|
|
keys := make([]string, 0, len(examples))
|
|
|
|
for k := range examples {
|
|
|
|
keys = append(keys, k)
|
|
|
|
}
|
2023-04-18 11:31:51 +00:00
|
|
|
desc := keys[rand.Intn(len(keys))] //nolint:gosec
|
2023-04-18 01:59:33 +00:00
|
|
|
return desc, examples[desc]
|
|
|
|
}
|
2023-05-09 17:44:02 +00:00
|
|
|
|
2023-05-10 20:28:35 +00:00
|
|
|
func cheapHighlighting(s styles, code string) string {
|
2023-05-09 17:44:02 +00:00
|
|
|
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
|
|
|
|
}
|