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

Function stringFromMap

cli/plugins/args_extract.go:76–86  ·  view source on GitHub ↗

stringFromMap returns the first non-empty string value found for any of the given keys in the JSON map. Numbers and booleans are ignored — DescribeCall is for showing human-readable identifiers.

(m map[string]json.RawMessage, keys []string)

Source from the content-addressed store, hash-verified

74// of the given keys in the JSON map. Numbers and booleans are ignored
75// — DescribeCall is for showing human-readable identifiers.
76func stringFromMap(m map[string]json.RawMessage, keys []string) string {
77 for _, k := range keys {
78 if raw, ok := m[k]; ok {
79 var s string
80 if err := json.Unmarshal(raw, &s); err == nil && s != "" {
81 return s
82 }
83 }
84 }
85 return ""
86}
87
88// jsonString is the shorthand used by atomic-tool plugins (@read,
89// @search, @tree, @todo, …) that own the parsed JSON object directly.

Callers 3

stringFromJSONArgFunction · 0.85
jsonStringFunction · 0.85
extractNestedArgFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected