Adding nix shell and reworking some parser/local file manager stuff

This commit is contained in:
2026-01-23 23:09:56 -06:00
parent ad2e074991
commit 45cd325818
6 changed files with 48 additions and 16 deletions

View File

@@ -1,4 +1,6 @@
using System.Reflection.Metadata;
using SzLib;
using SzLib.DataObjects;
namespace SzCli;
@@ -18,10 +20,16 @@ public class LocalFileManager : ISzFileManager
}
}
public string DatasetsPath => Path.Combine(DataPath, "datasets");
public bool SaveFile(string path, string fileContent)
{
try
{
var dir = Path.GetDirectoryName(path);
if (dir is null) return false;
Directory.CreateDirectory(dir);
File.WriteAllText(path, fileContent);
return true;
}
@@ -31,4 +39,17 @@ public class LocalFileManager : ISzFileManager
return false;
}
}
}
public string? LoadFile(string path)
{
try
{
return File.ReadAllText(path);
}
catch (Exception e)
{
Console.WriteLine($"Error saving file: {e.Message}");
return null;
}
}
}

View File

@@ -19,8 +19,8 @@ public class Program
Console.WriteLine("Attempting to load dataset...");
var loadedDataset = parser.LoadDataset(dataset.Id);
Console.WriteLine($"Successfully loaded dataset? {loadedDataset != null}. Id is {loadedDataset.Id}");
Console.WriteLine($"Successfully loaded dataset? {loadedDataset != null}. Id is {loadedDataset?.Id}");
Console.WriteLine(loadedDataset.DataObjects["test"].Fields["value"].Value);
Console.WriteLine(loadedDataset?.DataObjects["test"].Fields["value"].Value);
}
}