MCPcopy Index your code
hub / github.com/devspace-sh/devspace / main

Function main

docs/hack/cli/main.go:28–101  ·  view source on GitHub ↗

Run executes the command logic

()

Source from the content-addressed store, hash-verified

26
27// Run executes the command logic
28func main() {
29 filePrepender := func(filename string) string {
30 name := filepath.Base(filename)
31 base := strings.TrimSuffix(name, path.Ext(name))
32 command := strings.Split(base, "_")
33 title := strings.Join(command, " ")
34 sidebarLabel := title
35 l := len(command)
36
37 if l > 1 {
38 matches, err := filepath.Glob(cliDocsDir + "/devspace_" + command[1])
39 if err != nil {
40 log.Fatal(err)
41 }
42
43 if len(matches) > 2 {
44 sidebarLabel = command[l-1]
45 }
46 }
47
48 return fmt.Sprintf(headerTemplate, title, sidebarLabel)
49 }
50
51 linkHandler := func(name string) string {
52 base := strings.TrimSuffix(name, path.Ext(name))
53 if base == "devspace" {
54 base = "README"
55 }
56 return strings.ToLower(base) + ".md"
57 }
58
59 f := factory.DefaultFactory()
60 rootCmd := cmd.BuildRoot(f, true)
61
62 err := doc.GenMarkdownTreeCustom(rootCmd, cliDocsDir, filePrepender, linkHandler)
63 if err != nil {
64 log.Fatal(err)
65 }
66
67 err = filepath.Walk(cliDocsDir, func(path string, info os.FileInfo, err error) error {
68 if err != nil {
69 return err
70 }
71 stat, err := os.Stat(path)
72 if err != nil {
73 return err
74 }
75
76 if stat.IsDir() {
77 return nil
78 }
79
80 content, err := os.ReadFile(path)
81 if err != nil {
82 return err
83 }
84
85 newContents := fixSynopsisRegexp.ReplaceAllString(string(content), "$2$3$7$8```\n$4\n```\n\n\n## Flags$10\n## Global & Inherited Flags$13")

Callers

nothing calls this directly

Calls 5

DefaultFactoryFunction · 0.92
BuildRootFunction · 0.92
NameMethod · 0.65
FatalMethod · 0.45
IsDirMethod · 0.45

Tested by

no test coverage detected