MCPcopy Create free account
hub / github.com/driangle/taskmd / runTemplatesList

Function runTemplatesList

apps/cli/internal/cli/templates_cmd.go:50–77  ·  view source on GitHub ↗
(_ *cobra.Command, _ []string)

Source from the content-addressed store, hash-verified

48}
49
50func runTemplatesList(_ *cobra.Command, _ []string) error {
51 if err := ValidateFormat(templatesFormat, []string{"table", "json", "yaml"}); err != nil {
52 return err
53 }
54
55 projectRoot := resolveProjectRoot()
56 userHome, _ := os.UserHomeDir()
57
58 templates := template.Discover(projectRoot, userHome)
59
60 items := make([]templateListItem, len(templates))
61 for i, tmpl := range templates {
62 items[i] = templateListItem{
63 Name: tmpl.Name,
64 Description: tmpl.Description,
65 Source: tmpl.Source,
66 }
67 }
68
69 switch templatesFormat {
70 case "json":
71 return WriteJSON(os.Stdout, items)
72 case "yaml":
73 return WriteYAML(os.Stdout, items)
74 default:
75 return outputTemplatesTable(items)
76 }
77}
78
79func outputTemplatesTable(items []templateListItem) error {
80 if len(items) == 0 {

Callers 1

Calls 5

ValidateFormatFunction · 0.85
resolveProjectRootFunction · 0.85
WriteJSONFunction · 0.85
WriteYAMLFunction · 0.85
outputTemplatesTableFunction · 0.85

Tested by 1