-
Notifications
You must be signed in to change notification settings - Fork 295
/
Copy pathmain.go
48 lines (40 loc) · 890 Bytes
/
main.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
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"fmt"
"log"
"os"
"path"
"path/filepath"
"strings"
gptscript "github.com/gptscript-ai/gptscript/pkg/cli"
"github.com/spf13/cobra/doc"
)
const fmTemplate = `---
title: "%s"
---
`
func main() {
cmd := gptscript.New()
cmd.DisableAutoGenTag = true
files, err := filepath.Glob("docs/docs/04-command-line-reference/gptscript_*.md")
if err != nil {
log.Fatal(err)
}
for _, f := range files {
if err := os.Remove(f); err != nil {
log.Fatal(err)
}
}
err = doc.GenMarkdownTreeCustom(cmd, "docs/docs/04-command-line-reference", filePrepender, linkHandler)
if err != nil {
log.Fatal(err)
}
}
func filePrepender(filename string) string {
name := filepath.Base(filename)
base := strings.TrimSuffix(name, path.Ext(name))
return fmt.Sprintf(fmTemplate, strings.ReplaceAll(base, "_", " "))
}
func linkHandler(name string) string {
return name
}