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

Function getFlagReference

docs/hack/functions/main.go:181–222  ·  view source on GitHub ↗
(functionName, functionFile string, flagRef reflect.Type, partialImports *[]string, pageContent string)

Source from the content-addressed store, hash-verified

179}
180
181func getFlagReference(functionName, functionFile string, flagRef reflect.Type, partialImports *[]string, pageContent string) string {
182 flagPartialContent := ""
183
184 for i := 0; i < flagRef.NumField(); i++ {
185 flag := flagRef.Field(i)
186 if flag.Anonymous {
187 flagPartialContent = flagPartialContent + getFlagReference(functionName, functionFile, flag.Type, partialImports, pageContent)
188 continue
189 }
190
191 long := flag.Tag.Get("long")
192 if long == "" {
193 continue
194 }
195
196 short := flag.Tag.Get("short")
197 description := flag.Tag.Get("description")
198
199 if short != "" {
200 short = " / -" + short
201 }
202
203 anchorName := functionName + "-" + long
204 flagContent := fmt.Sprintf(util.TemplateFunctionRef, false, "", "#### ", "--"+long+short, flag.Type.String(), "", "", false, anchorName, description, "")
205
206 flagFile := fmt.Sprintf(functionPartialBasePath+"%s/%s.mdx", functionName, long)
207 err := os.MkdirAll(filepath.Dir(flagFile), os.ModePerm)
208 if err != nil {
209 panic(err)
210 }
211
212 err = os.WriteFile(flagFile, []byte(flagContent), os.ModePerm)
213 if err != nil {
214 panic(err)
215 }
216
217 flagPartialContent = flagPartialContent + fmt.Sprintf(util.TemplatePartialUse, util.GetPartialImportName(flagFile))
218 *partialImports = append(*partialImports, flagFile)
219 }
220
221 return flagPartialContent
222}
223
224const groupImages = "Images"
225const groupDeployments = "Deployments"

Callers 1

mainFunction · 0.85

Calls 3

GetPartialImportNameFunction · 0.92
GetMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected