Adding nix shell and reworking some parser/local file manager stuff
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user