| 1 | #nullable enable |
| 2 | |
| 3 | using System.IO; |
| 4 | using CascadeIDE.Services; |
| 5 | |
| 6 | namespace CascadeIDE.Features.Workspace.DataAcquisition; |
| 7 | |
| 8 | /// <summary>Чтение <c>.cascade/workspace.toml</c> из корня workspace (ADR 0102).</summary> |
| 9 | public static class RepositoryWorkspaceTomlLoader |
| 10 | { |
| 11 | public static string GetWorkspaceTomlPath(string workspaceRoot) => |
| 12 | Path.Combine(workspaceRoot.Trim(), ".cascade", "workspace.toml"); |
| 13 | |
| 14 | public static RepositoryWorkspaceToml? TryLoad(string? workspaceRoot) |
| 15 | { |
| 16 | if (string.IsNullOrWhiteSpace(workspaceRoot)) |
| 17 | return null; |
| 18 | |
| 19 | var path = GetWorkspaceTomlPath(workspaceRoot); |
| 20 | if (!WorkspaceTextFileReader.TryReadAllText(path, out var text)) |
| 21 | return null; |
| 22 | |
| 23 | try |
| 24 | { |
| 25 | return CascadeTomlSerializer.Deserialize<RepositoryWorkspaceToml>(text); |
| 26 | } |
| 27 | catch |
| 28 | { |
| 29 | return null; |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | |
View only · write via MCP/CIDE