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

Method PathCommand

pkg/wshrpc/wshserver/wshserver.go:1413–1452  ·  view source on GitHub ↗
(ctx context.Context, data wshrpc.PathCommandData)

Source from the content-addressed store, hash-verified

1411}
1412
1413func (ws *WshServer) PathCommand(ctx context.Context, data wshrpc.PathCommandData) (string, error) {
1414 pathType := data.PathType
1415 openInternal := data.Open
1416 openExternal := data.OpenExternal
1417 var path string
1418 switch pathType {
1419 case "config":
1420 path = wavebase.GetWaveConfigDir()
1421 case "data":
1422 path = wavebase.GetWaveDataDir()
1423 case "log":
1424 path = filepath.Join(wavebase.GetWaveDataDir(), "waveapp.log")
1425 }
1426
1427 if openInternal && openExternal {
1428 return "", fmt.Errorf("open and openExternal cannot both be true")
1429 }
1430
1431 if openInternal {
1432 _, err := ws.CreateBlockCommand(ctx, wshrpc.CommandCreateBlockData{
1433 TabId: data.TabId,
1434 BlockDef: &waveobj.BlockDef{Meta: map[string]any{
1435 waveobj.MetaKey_View: "preview",
1436 waveobj.MetaKey_File: path,
1437 }},
1438 Ephemeral: true,
1439 Focused: true,
1440 })
1441
1442 if err != nil {
1443 return path, fmt.Errorf("error opening path: %w", err)
1444 }
1445 } else if openExternal {
1446 err := open.Run(path)
1447 if err != nil {
1448 return path, fmt.Errorf("error opening path: %w", err)
1449 }
1450 }
1451 return path, nil
1452}
1453
1454func (ws *WshServer) FetchSuggestionsCommand(ctx context.Context, data wshrpc.FetchSuggestionsData) (*wshrpc.FetchSuggestionsResponse, error) {
1455 return suggestion.FetchSuggestions(ctx, data)

Callers

nothing calls this directly

Calls 4

CreateBlockCommandMethod · 0.95
GetWaveConfigDirFunction · 0.92
GetWaveDataDirFunction · 0.92
RunMethod · 0.80

Tested by

no test coverage detected