MCPcopy Index your code
hub / github.com/docker/cli / loadLongDescription

Function loadLongDescription

man/generate.go:71–109  ·  view source on GitHub ↗
(parentCommand *cobra.Command, path string)

Source from the content-addressed store, hash-verified

69}
70
71func loadLongDescription(parentCommand *cobra.Command, path string) error {
72 for _, cmd := range parentCommand.Commands() {
73 cmd.DisableFlagsInUseLine = true
74 if cmd.Name() == "" {
75 continue
76 }
77 fullpath := filepath.Join(path, cmd.Name()+".md")
78
79 if cmd.HasSubCommands() {
80 if err := loadLongDescription(cmd, filepath.Join(path, cmd.Name())); err != nil {
81 return err
82 }
83 }
84
85 if _, err := os.Stat(fullpath); err != nil {
86 log.Printf("WARN: %s does not exist, skipping\n", fullpath)
87 continue
88 }
89
90 log.Printf("INFO: %s found\n", fullpath)
91 content, err := os.ReadFile(fullpath)
92 if err != nil {
93 return err
94 }
95 cmd.Long = string(content)
96
97 fullpath = filepath.Join(path, cmd.Name()+"-example.md")
98 if _, err := os.Stat(fullpath); err != nil {
99 continue
100 }
101
102 content, err = os.ReadFile(fullpath)
103 if err != nil {
104 return err
105 }
106 cmd.Example = string(content)
107 }
108 return nil
109}
110
111func run() error {
112 opts := &options{}

Callers 1

genFunction · 0.85

Calls 1

NameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…