MCPcopy Create free account
hub / github.com/diillson/chatcli / parseDocsFlattenCrawlArgs

Function parseDocsFlattenCrawlArgs

cli/plugins/builtin_docsflatten.go:346–361  ·  view source on GitHub ↗

parseDocsFlattenCrawlArgs extracts the web-crawl source ("url") and its bounds (maxPages/maxDepth/sameHost), supporting both camelCase and kebab-case keys.

(raw map[string]json.RawMessage, out *docsFlattenArgs)

Source from the content-addressed store, hash-verified

344// bounds (maxPages/maxDepth/sameHost), supporting both camelCase and
345// kebab-case keys.
346func parseDocsFlattenCrawlArgs(raw map[string]json.RawMessage, out *docsFlattenArgs) {
347 out.URL = jsonString(raw, "url", "seed")
348 if v, ok := raw["maxPages"]; ok && len(v) > 0 {
349 out.MaxPages = jsonInt(raw, "maxPages")
350 } else if _, ok := raw["max-pages"]; ok {
351 out.MaxPages = jsonInt(raw, "max-pages")
352 }
353 if v, ok := raw["maxDepth"]; ok && len(v) > 0 {
354 out.MaxDepth = jsonInt(raw, "maxDepth")
355 } else if _, ok := raw["max-depth"]; ok {
356 out.MaxDepth = jsonInt(raw, "max-depth")
357 }
358 if v, present := jsonBoolLookup(raw, "sameHost", "same-host"); present {
359 out.SameHost = v
360 }
361}
362
363// validateDocsFlattenSource enforces that exactly one of root|repo|url is set
364// and sanity-checks the url source (scheme + non-negative bounds).

Callers 1

parseDocsFlattenArgsFunction · 0.85

Calls 3

jsonStringFunction · 0.85
jsonIntFunction · 0.85
jsonBoolLookupFunction · 0.85

Tested by

no test coverage detected