(ctx context.Context, data wshrpc.PathCommandData)
| 1411 | } |
| 1412 | |
| 1413 | func (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 | |
| 1454 | func (ws *WshServer) FetchSuggestionsCommand(ctx context.Context, data wshrpc.FetchSuggestionsData) (*wshrpc.FetchSuggestionsResponse, error) { |
| 1455 | return suggestion.FetchSuggestions(ctx, data) |
nothing calls this directly
no test coverage detected