MCPcopy
hub / github.com/urfave/cli / GfmrunActionFunc

Function GfmrunActionFunc

scripts/build.go:296–434  ·  view source on GitHub ↗
(ctx context.Context, cmd *cli.Command)

Source from the content-addressed store, hash-verified

294}
295
296func GfmrunActionFunc(ctx context.Context, cmd *cli.Command) error {
297 docsDir := filepath.Join(cmd.String("top-dir"), "docs")
298
299 bash, err := exec.LookPath("bash")
300 if err != nil {
301 return err
302 }
303
304 os.Setenv("SHELL", bash)
305
306 tmpDir, err := os.MkdirTemp("", "urfave-cli*")
307 if err != nil {
308 return err
309 }
310
311 wd, err := os.Getwd()
312 if err != nil {
313 return err
314 }
315
316 if err := os.Chdir(tmpDir); err != nil {
317 return err
318 }
319
320 fmt.Fprintf(cmd.ErrWriter, "# ---> workspace/TMPDIR is %q\n", tmpDir)
321
322 if err := runCmd(ctx, "go", "work", "init", docsDir); err != nil {
323 return err
324 }
325
326 os.Setenv("TMPDIR", tmpDir)
327
328 if err := os.Chdir(wd); err != nil {
329 return err
330 }
331
332 dirPath := cmd.Args().Get(0)
333 if dirPath == "" {
334 dirPath = "README.md"
335 }
336
337 walk := cmd.Bool("walk")
338 sources := []string{}
339
340 if walk {
341 // Walk the directory and find all markdown files.
342 err := filepath.Walk(dirPath, func(path string, info os.FileInfo, err error) error {
343 if err != nil {
344 return err
345 }
346
347 if info.IsDir() {
348 return nil
349 }
350
351 if filepath.Ext(path) != ".md" {
352 return nil
353 }

Callers

nothing calls this directly

Calls 6

runCmdFunction · 0.85
ArgsMethod · 0.80
BoolMethod · 0.80
WalkMethod · 0.80
GetMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected