MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / parseMetaValue

Function parseMetaValue

cmd/wsh/cmd/wshcmd-setmeta.go:62–95  ·  view source on GitHub ↗
(setVal string)

Source from the content-addressed store, hash-verified

60}
61
62func parseMetaValue(setVal string) (any, error) {
63 if setVal == "" || setVal == "null" {
64 return nil, nil
65 }
66 if setVal == "true" {
67 return true, nil
68 }
69 if setVal == "false" {
70 return false, nil
71 }
72 if setVal[0] == '[' || setVal[0] == '{' || setVal[0] == '"' {
73 var val any
74 err := json.Unmarshal([]byte(setVal), &val)
75 if err != nil {
76 return nil, fmt.Errorf("invalid json value: %v", err)
77 }
78 return val, nil
79 }
80
81 // Try parsing as integer
82 ival, err := strconv.ParseInt(setVal, 0, 64)
83 if err == nil {
84 return ival, nil
85 }
86
87 // Try parsing as float
88 fval, err := strconv.ParseFloat(setVal, 64)
89 if err == nil {
90 return fval, nil
91 }
92
93 // Fallback to string
94 return setVal, nil
95}
96
97func setNestedValue(meta map[string]any, path []string, value any) {
98 // For single key, just set directly

Callers 2

TestParseMetaValueFunction · 0.85
parseMetaSetsFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestParseMetaValueFunction · 0.68