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

Function printContextFilesBySource

apps/cli/internal/cli/context.go:189–224  ·  view source on GitHub ↗

printContextFilesBySource groups files by source type and prints them.

(w *os.File, files []taskcontext.FileEntry, r *lipgloss.Renderer)

Source from the content-addressed store, hash-verified

187
188// printContextFilesBySource groups files by source type and prints them.
189func printContextFilesBySource(w *os.File, files []taskcontext.FileEntry, r *lipgloss.Renderer) {
190 // Group scope files by scope name
191 scopeGroups := make(map[string][]taskcontext.FileEntry)
192 var scopeOrder []string
193 var explicit []taskcontext.FileEntry
194
195 for _, f := range files {
196 if strings.HasPrefix(f.Source, "scope:") {
197 name := strings.TrimPrefix(f.Source, "scope:")
198 if _, exists := scopeGroups[name]; !exists {
199 scopeOrder = append(scopeOrder, name)
200 }
201 scopeGroups[name] = append(scopeGroups[name], f)
202 } else {
203 explicit = append(explicit, f)
204 }
205 }
206
207 for _, name := range scopeOrder {
208 fmt.Fprintf(w, "\n%s\n", formatLabel(fmt.Sprintf("Scope files (%s):", name), r))
209 for _, f := range scopeGroups[name] {
210 printContextFile(w, f, r)
211 }
212 }
213
214 if len(explicit) > 0 {
215 fmt.Fprintf(w, "\n%s\n", formatLabel("Explicit files:", r))
216 for _, f := range explicit {
217 printContextFile(w, f, r)
218 }
219 }
220
221 if len(files) == 0 {
222 fmt.Fprintf(w, "\n%s\n", formatDim("No context files found.", r))
223 }
224}
225
226func printContextFile(w *os.File, f taskcontext.FileEntry, r *lipgloss.Renderer) {
227 path := f.Path

Callers 1

outputContextTextFunction · 0.85

Calls 3

formatLabelFunction · 0.85
printContextFileFunction · 0.85
formatDimFunction · 0.85

Tested by

no test coverage detected