MCPcopy
hub / github.com/wavetermdev/waveterm / GetVarCommand

Method GetVarCommand

pkg/wshrpc/wshserver/wshserver.go:1354–1365  ·  view source on GitHub ↗
(ctx context.Context, data wshrpc.CommandVarData)

Source from the content-addressed store, hash-verified

1352}
1353
1354func (ws *WshServer) GetVarCommand(ctx context.Context, data wshrpc.CommandVarData) (*wshrpc.CommandVarResponseData, error) {
1355 _, fileData, err := filestore.WFS.ReadFile(ctx, data.ZoneId, data.FileName)
1356 if err == fs.ErrNotExist {
1357 return &wshrpc.CommandVarResponseData{Key: data.Key, Exists: false}, nil
1358 }
1359 if err != nil {
1360 return nil, fmt.Errorf("error reading blockfile: %w", err)
1361 }
1362 envMap := envutil.EnvToMap(string(fileData))
1363 value, ok := envMap[data.Key]
1364 return &wshrpc.CommandVarResponseData{Key: data.Key, Exists: ok, Val: value}, nil
1365}
1366
1367func (ws *WshServer) GetAllVarsCommand(ctx context.Context, data wshrpc.CommandVarData) ([]wshrpc.CommandVarResponseData, error) {
1368 _, fileData, err := filestore.WFS.ReadFile(ctx, data.ZoneId, data.FileName)

Callers

nothing calls this directly

Calls 2

EnvToMapFunction · 0.92
ReadFileMethod · 0.80

Tested by

no test coverage detected