(cmd *cobra.Command, dir string)
| 11 | ) |
| 12 | |
| 13 | func GenYamlTree(cmd *cobra.Command, dir string) error { |
| 14 | commands := getCommands(cmd) |
| 15 | |
| 16 | for _, c := range commands { |
| 17 | commandPath := strings.ReplaceAll(c.Name, " ", "_") |
| 18 | filename := filepath.Join(dir, fmt.Sprintf("%s.yml", commandPath)) |
| 19 | f, err := os.Create(filename) |
| 20 | if err != nil { |
| 21 | return err |
| 22 | } |
| 23 | defer f.Close() |
| 24 | |
| 25 | // Write a comment to the file, ignoring vale errors |
| 26 | _, err = f.WriteString("# <!-- vale off -->\n") |
| 27 | if err != nil { |
| 28 | return err |
| 29 | } |
| 30 | |
| 31 | encoder := yaml.NewEncoder(f) |
| 32 | defer encoder.Close() |
| 33 | |
| 34 | err = encoder.Encode(c) |
| 35 | if err != nil { |
| 36 | return err |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | return nil |
| 41 | } |
nothing calls this directly
no test coverage detected