MCPcopy Create free account
hub / github.com/compozy/agh / readInput

Function readInput

internal/cli/docpost/docpost.go:211–234  ·  view source on GitHub ↗
(ctx context.Context, srcDir string, entry fs.DirEntry)

Source from the content-addressed store, hash-verified

209}
210
211func readInput(ctx context.Context, srcDir string, entry fs.DirEntry) (input, bool, error) {
212 fullPath := filepath.Join(srcDir, entry.Name())
213 if err := ensureContext(ctx, fmt.Sprintf("read %s", fullPath)); err != nil {
214 return input{}, false, err
215 }
216 if entry.IsDir() || !strings.HasSuffix(entry.Name(), ".md") {
217 return input{}, false, nil
218 }
219 base := strings.TrimSuffix(entry.Name(), ".md")
220 segments, err := commandSegments(entry.Name(), base)
221 if err != nil {
222 return input{}, false, err
223 }
224 data, err := os.ReadFile(fullPath)
225 if err != nil {
226 return input{}, false, fmt.Errorf("docpost: read %s: %w", fullPath, err)
227 }
228 return input{
229 fileName: entry.Name(),
230 baseName: base,
231 segments: segments,
232 raw: string(data),
233 }, true, nil
234}
235
236func commandSegments(fileName string, base string) ([]string, error) {
237 if base == docpostAghKey {

Callers 1

readInputsFunction · 0.85

Calls 4

ensureContextFunction · 0.85
commandSegmentsFunction · 0.85
NameMethod · 0.65
ReadFileMethod · 0.65

Tested by

no test coverage detected