MCPcopy Create free account
hub / github.com/wavetermdev/waveterm / filterMetaKeys

Function filterMetaKeys

cmd/wsh/cmd/wshcmd-getmeta.go:37–73  ·  view source on GitHub ↗
(meta map[string]interface{}, keys []string)

Source from the content-addressed store, hash-verified

35}
36
37func filterMetaKeys(meta map[string]interface{}, keys []string) map[string]interface{} {
38 result := make(map[string]interface{})
39
40 // Process each requested key
41 for _, key := range keys {
42 if strings.HasSuffix(key, ":*") {
43 // Handle pattern matching
44 prefix := strings.TrimSuffix(key, "*")
45 baseKey := strings.TrimSuffix(prefix, ":")
46
47 if getMetaClearPrefix {
48 result[key] = true
49 }
50
51 // Include the base key without colon if it exists
52 if val, exists := meta[baseKey]; exists {
53 result[baseKey] = val
54 }
55
56 // Include all keys with the prefix
57 for k, v := range meta {
58 if strings.HasPrefix(k, prefix) {
59 result[k] = v
60 }
61 }
62 } else {
63 // Handle exact key match
64 if val, exists := meta[key]; exists {
65 result[key] = val
66 } else {
67 result[key] = nil
68 }
69 }
70 }
71
72 return result
73}
74
75func getMetaRun(cmd *cobra.Command, args []string) (rtnErr error) {
76 defer func() {

Callers 1

getMetaRunFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected