MCPcopy Index your code
hub / github.com/coder/coder / genTree

Function genTree

scripts/clidocgen/gen.go:123–153  ·  view source on GitHub ↗
(dir string, cmd *serpent.Command, wroteLog map[string]*serpent.Command)

Source from the content-addressed store, hash-verified

121}
122
123func genTree(dir string, cmd *serpent.Command, wroteLog map[string]*serpent.Command) error {
124 if cmd.Hidden {
125 return nil
126 }
127
128 path := filepath.Join(dir, fmtDocFilename(cmd))
129
130 var buf strings.Builder
131 err := writeCommand(&buf, cmd)
132 if err != nil {
133 return err
134 }
135
136 err = atomicwrite.File(path, []byte(buf.String()))
137 if err != nil {
138 return err
139 }
140
141 flog.Successf(
142 "wrote\t%s",
143 path,
144 )
145 wroteLog[path] = cmd
146 for _, sub := range cmd.Children {
147 err = genTree(dir, sub, wroteLog)
148 if err != nil {
149 return err
150 }
151 }
152 return nil
153}

Callers 1

mainFunction · 0.85

Calls 4

FileFunction · 0.92
fmtDocFilenameFunction · 0.85
writeCommandFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected